This question has been flagged
3 Replies
15111 Views

Hello,

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.

Sometimes it is saving while editing and sometimes not !!

I don't know what is happening because this is just a small customization.


This is the view:

<odoo>
  <data>
      <record id="account_move_line_delivery" model="ir.ui.view">
          <field name="name">account.move.delivery</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']/tree/field[@name='quantity']" position="before">
                <field name="delivery_date"/>
            </xpath>
          </field>
      </record>
  </data>
</odoo>


This is the python code:

from odoo import api, fields, models
class AccountMoveLine(models.Model):
    _inherit = 'account.move.line'
    delivery_date = fields.Date(string="Delivery Date")

Avatar
Discard
Best Answer

Hi,
In odoo 13 we are using single model for both the invoice and for journal entries. So while we create a field in account.move.line we have to mention the new field in both the notebook page. one in the invoice line notebook page and other in the journal item notebook page. If you want the field to view only in invoice line then you can make the field invisible in journal entry page by setting the attribute invisible = 1. But it is required you to mention the field in both the invoice line and journal line pages.
Refer the code below

<odoo> 
<data>
<record id = "account_move_line_delivery" model = "ir.ui.view" >
<field name = "name" > account.move.delivery </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'] / tree / field [@ name = 'quantity']"position = "before" >
<field name = "delivery_date" />
</xpath>
<xpath expr = "// field [@ name = 'line_ids'] / tree / field [@ name = 'account_id']" position = "before" >
<field name = "delivery_date" />
</xpath>
</field>
</record>
</data>
</odoo>

Regards

Avatar
Discard

This worked for me, thank you!

I am use your answer but did not work with me , any help plz

Author Best Answer

I tried Cybrosys Techno Solutions Pvt.Ltd answer.
It is still not saving !!


Avatar
Discard

if you want to save a custom field ,you need to add >>force_save="1" in your xml view.

Hi Sayed, maybe dou you found any solution for this problem, i'm tried too Cybrosys Techno Solutions Pvt.Ltd answer, but it is still not working, thanks!!

Best Answer

Hello,

i am getting same issue, i am not able to save added fields in invoice line (account.move.line): 

    field1= fields.Float(string='field1',default=0.0, digits='Product Unit of Measure',readonly=False)
field2= fields.Float(string='field2',default=0.0, digits='Product Unit of Measure',readonly=False)
 @api.onchange('field1','field2')
def _onchange_fields(self):
if self.field1 ==0 :
self.quantity = self.field2
else:
self.quantity = self.field1 * self.field2









Avatar
Discard