Hello all,
We are on Odoo 10.
I have declared a new many2one field customer_of_division_id in the model sale.order and in the model account.invoice.
I have added the field on the form view of both models this way :
<field name="customer_of_division_id"/>
My field is displayed like this in a new sale order :
And my field is displayed like this on a new invoice :
Why is it not the same on both? How to avoid all the address displayed on the second one?
EDIT #1 : Here is all the code
In the Python
class SaleOrder(models.Model):
_inherit = "sale.order"
customer_of_division_id = fields.Many2one(related="partner_id.customer_of_division_id", string='Customer of the division')
class AccountInvoice(models.Model):
_inherit = "account.invoice"
customer_of_division_id = fields.Many2one(related="partner_id.customer_of_division_id", string='Customer of the division', readonly=True)
In the XML
<record id="invoice_form" model="ir.ui.view">
<field name="name">account.invoice.form.inherit.vtm2</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_shipping_id']" position="attributes">
<attribute name="domain">['&',('parent_id','=',partner_id),('type','=','delivery')]</attribute>
</xpath>
<field name="payment_term_id" position="after">
<field name="customer_of_division_id"/>
</field>
</field>
</record>
<record id="view_order_form" model="ir.ui.view">
<field name="name">sale.view.order.form.inherit.vtm2</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_shipping_id']" position="attributes">
<attribute name="domain">['&',('parent_id','=',partner_id),('type','=','delivery')]</attribute>
</xpath>
<field name="payment_term_id" position="after">
<field name="customer_of_division_id" attrs="{'readonly': [('state', 'not in', ('draft','sent'))]}"/>
</field>
</field>
</record>
Hi, can you paste the code of your field definition and also xml inheritance code? How you pass value to the Many2one field on invoice?
If I remove the 'Readonly=True' in my Python declaration, It is well displayed. Thanks. But it doesn't help me to understand why all the address was displayed..???!!! Big thanks
Sorry. I thought that it was an easy problem. I have put my code above. Thanks.