콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2953 화면

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
4912
0
1월 23
1535
1
11월 22
2207
2
10월 21
3087
0
2월 20
3252