Reputation: 71
I faced a problem while adding a new field to invoice_line_ids field in account.move Actually, the field has been added but it is not saving the value whenever I create a new invoice or edit an invoice.
I tried this, but It is still not saving!! https://github.com/odoo/odoo/issues/40915#issuecomment-574624912
this is my code:
class account_move_line(models.Model):
_inherit = "account.move.line"
detail_ids = fields.One2many(string="Details",
comodel_name="account.move.line.detail",
inverse_name="line_id")
class account_move_line_detail(models.Model):
_name = "account.move.line.detail"
line_id = fields.Many2one(string="Line", comodel_name="account.move.line", ondelete="cascade")
value = fields.Char(string="Value")
<record id='account_view_move_form' model='ir.ui.view'>
<field name='name'>account.view.move.form</field>
<field name='model'>account.move</field>
<field name='inherit_id' ref='account.view_move_form' />
<field name='arch' type='xml'>
<xpath expr="//field[@name='invoice_line_ids']/form//field[@name='name']" position="after">
<field name="detail_ids">
<tree editable="bottom">
<field name="value"/>
</tree>
</field>
</xpath>
<xpath expr="//field[@name='line_ids']/form/group" position="inside">
<field name="detail_ids" invisible="1"/>
</xpath>
</field>
</record>
thanks in advance!!!
Upvotes: 0
Views: 2792
Reputation: 372
Please define the field you have added newly to account move line in 'line_ids' o2m tree view.
That is inherit the account move form view and in the line_ids tree view inside the form view please define your new field as invisible
Upvotes: 1
Reputation: 17
use attribute force_save="1" in your field attribute in xml like this for example. then your field will save data in account.move.line
Upvotes: 0