コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
2905 ビュー

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"


アバター
破棄
著作者 最善の回答

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:







アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
4
2月 24
4613
0
1月 23
1490
1
11月 22
2166
2
10月 21
3067
0
2月 20
3237