'Adding new field on invoice_line_ids in account.move (odoo 13)
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!!!
Solution 1:[1]
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
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Anitha Das B |
Solution 2 | Syed Hamza Bukhari |