I'm using v10 and I'm trying to add few fields to 'res.partner' and then add the same fields to other forms.
Here are my .py and .xml:
class add_vendor_ship_carrier(models.Model):
_inherit = 'res.partner'
ship_carrier = fields.Char('Ship Carrier')
ship_carrier_account = fields.Char('Ship Carrier Account')
class add_to_sales_order(models.Model):
_inherit = 'sale.order'
ship_carrier = fields.Char(related='partner_id.ship_carrier')
ship_carrier_account = fields.Char(related='partner_id.ship_carrier_account')
class add_to_purchase_order(models.Model):
_inherit = 'purchase.order'
ship_carrier = fields.Char(related='partner_id.ship_carrier')
ship_carrier_account = fields.Char(related='partner_id.ship_carrier_account')
<record id="ship_carrier_supplier_form" model="ir.ui.view">
<field name="name">vendor.carrier.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="priority">36</field>
<field name="arch" type="xml">
<field name="property_stock_supplier" position="after">
<field name="ship_carrier"/>
<field name="ship_carrier_account"/>
</field>
</field>
</record>
<record id="ship_carrier_sale_order_form" model="ir.ui.view">
<field name="name">customer.carrier.sale.order.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="priority">36</field>
<field name="arch" type="xml">
<field name="fiscal_position_id" position="after">
<field name="ship_carrier"/>
<field name="ship_carrier_account"/>
</field>
</field>
</record>
<record id="supplier_carrier_purchase_order_form" model="ir.ui.view">
<field name="name">supplier.carrier.purchase.order.inherit</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="priority">36</field>
<field name="arch" type="xml">
<field name="date_planned" position="after">
<field name="ship_carrier"/>
<field name="ship_carrier_account"/>
</field>
</field>
</record>
It added my 2 custom fields to 'res.partner' and to 'sale.order' forms, but not to 'purchase.order' form.
I'm getting the following error:
ValueError: Can't validate view:
Field `ship_carrier` does not exist
I'm trying to use related fields to add them to multiple forms, but it doesn't work for purchase order for some reason.
What am I doing wrong and what is the easiest way to add a field to multiple forms?
Thanks for help in advance.