Skip to Content
Menu
This question has been flagged
2 Replies
2737 Views

I'm trying to extend the sale.order model to have a relation with an email chain model I've created in my custom module. So I created this:

 

    class sales_order_email_field(osv.Model):
        _name = 'sale.order'
        _inherit = 'sale.order'
        _columns = {
            'email_chain': fields.many2one(
                'sale.order_email.collection',
                'Email Chain',
                required=False
            )
        }

    sales_order_email_field()

and in my XML:

    <record id="view_res_sale_line_email_chain_form" model="ir.ui.view">
          <field name="name">sale.order.form.inherit</field>
          <field name="model">sale.order</field>
          <field name="type">form</field>
          <field name="priority" eval="8"/>
          <field name="inherit_id" ref="sale.view_order_form"/>
          <field name="arch" type="xml">
              <data>
                  <xpath expr="//field[@name='product_uom_qty']"
                         position="after">
                      <field name="email_chain"/>
                  </xpath>
              </data>
          </field>
      </record>

Buy I get an error message:

    Error details: Field `email_chain` does not exist

What am I doing wrong?

Avatar
Discard

Hi, Just make sure that your .py file is imported into __init__.py file. And then just install / upgrade your custom module.

Author

The python file is loaded.

Best Answer

You have created the field email_chain in sale.order model and adding it in the sale.order.line models view. For using your new field in the sale order's product line it must be created in sale.orderl.line model.

Avatar
Discard

Sry, but in this case the error message is why: Error details: Field `email_chain` does not exist? In my opinion this trouble is coming from lack the field, not?

Author

Ah that makes a lot of sense, my xpath was targeting the Order Line that's inline of the sales order, so the active model wasn't actually the sale order. Thanks.

Best Answer

Please try to restart the server, and reinstall your custom modul. Your field is not exists in sale_order model.

Avatar
Discard
Author

I tried that, I'm getting the same error.