Place button in one2many field tree view - odoo

I want to add button in one2many tree view line. I have placed button in tree view and these button shows successfully.
But when i click on button, it display form define against one2many field instead of function call.
Need guidance how to call function/form on button click.
<page name="component_line_id" string="Component Lines">
<field name="component_line_id">
<tree>
<field name="purchase_order_id" required="1"/>
<field name="description"/>
<field name="payable_amount"/>
<field name="file_name" string="Attachment"/>
<button string="Create Bill" name="create_bill" type="object" class="oe_highlight" icon="fa-icon_you_like"/>
<button string="View Bill" name="view_bill" type="object" class="oe_highlight" icon="fa-icon_you_like"/>
</tree>
<form string="Component Lines">
<group>
<group>
<field name="purchase_order_id"/>
<field name="description"/>
<field name="payable_amount"/>
</group>
<group>
<field name="attachment_file" filename="file_name"/>
<field name="file_name" invisible="1"/>
</group>
</group>
</form>
</field>
</page>

I think you need to save the record first to be able to run the button. Are you sure it was not on edit mode?

Related

odoo many2many show selection Odoo10

we have a list of items in one model named us_inventory_line. We have another model named ladings...
class inventory_line(models.Model):
# ...
lading_item = fields.Many2one('res.lading', ondelete='set null', string="lading", index=True)
class Lading(models.Model):
# ...
us_inventory_line_item = fields.One2many(comodel_name='rodals.us_inventory_line', string="shippments", inverse_name='lading_item')
In the form, we have just simply put the field that represent one2many:
<!-- Form -->
<record model="ir.ui.view" id="us_inventory_line_form_view">
<field name="name">lading.form</field>
<field name="model">rodals.lading</field>
<field name="arch" type="xml">
<form string="Invetory Line Form">
<sheet>
<group>
<field name="delivery_date"/>
<field name="us_inventory_line_item"/>
</group>
</sheet>
</form>
</field>
</record>
When the application is opened, when the user opens the lading page, he is only able to add new us_inventory_line.
How do we go about in order to connect the tow ? Like the user need to choose, from a list of us_inventory_line that does not have a lading (because if its has lading, this means that its already shipped).
Thank you very much for the help !
<record model="ir.ui.view" id="us_inventory_line_form_view">
<field name="name">lading.form</field>
<field name="model">rodals.lading</field>
<field name="arch" type="xml">
<form string="Invetory Line Form">
<sheet>
<group>
<field name="delivery_date"/>
<field name="us_inventory_line_item">
<tree string="US Inventory Item">
<field name="lading_item"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>

Show form field and tree view together odoo

I managed to add two custom fields to the settings by inheriting res.config.settings in a new module created. The xml page of the same is
<record id="op_product_fast_moving_parts_form" model="ir.ui.view">
<field name="name">Configure Fast Moving Parts</field>
<field name="model">fastmovingparts.config.settings</field>
<field name="arch" type="xml">
<form string="FastMoving">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<separator string="Configure Fast Moving Parts"/>
<group name="Configure Fast Moving Parts">
<field string="Minimum Quantity" name="fast_moving_parts_min_qty"/>
</group>
<group>
<field string="Interval" name="fast_moving_parts_chk_interval"/>
</group>
</form>
</field>
</record>
It is updating the settings when clicking on the Apply button.
Here I have one more requirement that I need to open a wizard on clicking Apply button which will display products tree. How can I achieve this?
Thanks in advance
I didn't get your question, but I think that you want to open a wizard on clicking Apply button which will display products tree.

Can't remove top "Save" button from Odoo

I want to remove the top "Save" button from the formview of my custom module.
I know that we perform this by setting write/create to false in the XML, which I did and can't figure out why it is still there.
My view:
<record id="view_module_genall_form" model="ir.ui.view">
<field name="name">module.genall.form</field>
<field name="model">module.genall</field>
<field name="arch" type="xml">
<form string="Automatically generate bills" edit="false" create="false" delete="false" write="false">
<button name="generate_all" type="object" string="Generate bills" icon="oe_highlight"/>
</form>
</field>
</record>
The related action:
<record model="ir.actions.act_window" id="action_module_genall">
<field name="name">Automatically generate bills</field>
<field name="res_model">alkivi.genall</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_module_genall_form" />
</record>
Do you have an idea ? Thanks!
From it's title it looks like the purpose of your form is to run a server method to perform some business logic.
For that you should use a Wizard instead of a regular Model: for that the module.genalshould be a models.TransientModel instead of a models.Model.

Passing active_id to action window in openerp7

I building a custom module in openerp version 7. I'm facing problems in trying to link an anchor tag in a kanban view item to an action window which will open the clicked on item in a form view.
Here's a sinppet of the kanban view
<a type="action" name="myaction">
<img t-att-src="kanban_image('vessel', 'image_medium', record.id.value)" class="oe_employee_picture" />
</a>
Here's the action that will be invoked on click
<record model="ir.actions.act_window" id="myaction">
<field name="name">Vessel</field>
<field name="res_model">vessel</field>
<field name="view_type">form</field>
<field name="view_id" ref="crew_management.view_crew_management_vessels_form"/>
<field name="view_mode">form</field>
<field name="context">{'id': active_id}</field>
</record>
Currently when clicking on the link it opens the correct form view but empty. It seems that the active id of the selected item is not passed somehow.
To pass the active id of an object use res_id instead.
<field name="context">{'res_id': active_id}</field>
The complete code would be
<a type="action" name="action_id">
<!-- Anything Here -->
</a
<record model="ir.actions.act_window" id="action_id">
<field name="name">demo</field>
<field name="res_model">demo</field>
<field name="view_type">form</field>
<field name="view_id" ref="my_module.demo_view_id"/>
<field name="view_mode">form</field>
<field name="context">{'res_id': active_id}</field>
</record>
try passing <field name="context">{'active_id': active_id}</field>

Customer Invoice validate button

I have created a button named 'Confirm' in customer invoice. When i click 'Confirm' button 'state1' will be 'confirmed'. I want to hide Validate button when 'state1'='draft' and show the Validate button when 'state1'='confirmed'. I tried below code but it is not working. Can anyone help me?
<!-- inherit account invoice form -->
<record id="invoice_form_inheritai" model="ir.ui.view">
<field name="name">account.invoice.form.inheritai</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<button name="invoice_print" position="after">
<field name="state1" invisible="1"/>
<button name="invoice_check" string="Confirm" type="object" attrs="{'invisible': [('state1','not in', ['draft'])]}" class="oe_highlight" groups="base.group_user"/>
</button>
<button name="invoice_open" position="replace">
<button name="invoice_open" state="draft" string="Validate" attrs="{'invisible': [('state1','!=', ['confirmed'])]}" groups="base.group_user"/>
</button>
</field>
</record>
<button name="invoice_open" string="Validate" attrs="{'invisible': [('state1','not in', ['confirmed']),('state','not in',['draft'])]}" groups="base.group_user"/>
Please avoid using both invisible attribute and states.
Try using 'states' instead of 'state'. And even attr won't be required. It will work automatically. Ex:
<button name="invoice_open" states="confirmed" string="Validate" groups="base.group_user"/>