Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
2892 Widoki

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"


Awatar
Odrzuć
Autor Najlepsza odpowiedź

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:







Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
lut 24
4607
0
sty 23
1489
1
lis 22
2162
2
paź 21
3066
0
lut 20
3237