I have a very strange problem concerning sale.order.line and sale.order. To the background: In the product.template there is a relation to a "Product Description" where I can store several Values (One2many).
When I choose a product in the the sale.order.line, the available descriptions are loaded also in a new relation to the sale.order.line. This is needed to change the description temporary.
I insert the available description lines with an onchange method which works fine. But the problem is when I am trying to insert a new record. When I click on "save" at the sale.order.line Odoo jumps back to the sale.order. When I am now saving the sale.order the one2many-entry values (description in the sale.order.line) disappear. The relation exist, but the fields of the description in the sale.order.line are empty. Can anybody help me. Thank you! Here are the code snippets:
Own model for the description:
#Product Description Name
class product_description_name(models.Model):
_name = 'x_article.product_description_name'
name = fields.Char(string="Bezeichnung", required=True)
product_description_ids = fields.One2many('x_article.product_description', 'pdm_id', string="Artikel")
class product_description(models.Model):
_name = 'x_article.product_description'
_order = 'sequence'
sequence = fields.Integer(string='Sequence', default=1)
pdm_id = fields.Many2one('x_article.product_description_name', string="Bezeichnung")
text = fields.Char(string="Eigenschaft")
article_id = fields.Many2one('product.template', string="Artikel")
sale_order_line_id = fields.Many2one('sale.order.line', string="Bestellposition")
on_doc = fields.Boolean(string="sämtliche Dokumente", default=False)
on_offer = fields.Boolean(string="Angebot/Webshop", default=False)
<xpath expr="//field[@name='order_line']/form//field[@name='name']" position="after">
<field name="name_offer" attrs="{'invisible': [('state','!=', 'draft')]}" />
<field name="id" invisible="1" />
<field name="article_description_ids" nolabel="1" context="{'default_sale_order_line_id': active_id}">
<tree editable="true">
<field name="sequence" widget="handle" />
<field name="pdm_id" options="{'no_create': True}" />
<field name="text" /> <field name="on_doc" />
<field name="on_offer" />
<field name="article_id" invisible="1" />
<field name="sale_order_line_id" />
</tree>
</field>
</xpath>