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

For the view when creating an invoice in the app "Invoicing" in Odoo 15, a new field "Unit" should be added to the "Invoice Lines" after the field "Quantity".
The field is supposed to be freely writable for each new line in the invoice lines and allowed to contain a text about the unit (e.g. Quantity: 34, Unit: "Hours") Unfortunately, I seem to address it incorrectly via my add on or miss something. I don't understand the error message during the installation, because exactly this field, where it says it is not available, I just want to add:

views/unit.xml: Please see here, somehow ic ant post real links or images or full xml code: gist.github.com/mholthausen/456c54d1e398e3f70b2066d4d9fdb3a9

models/unit.py:

from odoo import fields, models

class Unit(models.Model):
_inherit = 'account.move'

unit_field = fields.Char('Unit')

This error message then appears when trying to install the add on:

Field "unit_field" does not exist in model "account.move.line"


Avatar
Discard
Author Best Answer

Oh, thanks! The field is shown now in the view. But somehow the typed value isn't saved in the first try. Only if the invoice was created as a draft and you go into editing mode again, a value will be permanently saved there. For the other fields, the values are already permanently saved after the first creation of the invoice.


Edit:

Found out, that I nedded to add the field also into "line_ids" field, so i have two xpath- expressions now:







Avatar
Discard
Best Answer

Hi 

Add the field unit_field in account.move.line. In the view field is added inside the invoice_line_ids which is a on2many field that links account.move.line 

Try to add the field like this and install the module 


class Unit(models.Model):
_inherit = 'account.move.line'

unit_field = fields.Char('Unit')


Regards

Avatar
Discard
Related Posts Replies Views Activity
4
Feb 24
2783
0
Jan 23
816
1
Nov 22
1184
2
Oct 21
2110
0
Feb 20
2492