Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
2893 Visualizações

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
Cancelar
Autor Melhor resposta

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
Cancelar
Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
4
fev. 24
4607
0
jan. 23
1489
1
nov. 22
2162
2
out. 21
3066
0
fev. 20
3237