Hi I am using Odoo 11.
I am customizing the account.invoice model, and i'd like to add a reference to stock.production.lot in the account invoice lines. In other words, when the user adds a product in the invoice, i'd like him to choose a corresponding lot number from the available ones.
So what I need is some sort of domain_filter in order to let the lot selectbox be filled only with those lots whose id_product equals the id_product of the invoice line. However, im not sure on what syntax to use...
My custom invoice line model:
class CustomInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
_name = 'account.invoice.line'
lot_id = fields.Many2one('stock.production.lot', string='Lotto',
ondelete='restrict', index=True)
My view:
<odoo>
<data>
<record id="custom_invoice_view" model="ir.ui.view">
<field name="name">custom.invoice.view</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/tree[1]/field[@name='quantity']" position="before">
<field name="lot_id" domain = "???????"></field>
</xpath>
</field>
</record>
</data>
</odoo>
Thank you in advance,
Daniele
Dependent dropdown (selection) in odoo: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html