Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
5483 Vistas

Hello everyone
I made an overwrite on the create method function of the invoice lines in odoo 11. It sets the taxes in the field invoice_line_tax_ids based on another criteria. The thing is, after the creation of the invoice lines is done, in the database these results are all stored successfully, but at the erp end they won't show up, it says the fields is empty - no records. There is no computation on this field(at least not one I can found), so I really can not figure why the results from the database are not showing up.

Here is the create function for reference:​

@api.model
def create(self, vals):
invoice = self.env['account.invoice'].search([('id', '=', vals['invoice_id'])])
country = invoice.partner_id.country_id.id
cg = self.env['res.country.group'].search([('country_ids', 'in', country), ('invoice_line_account_vat', '!=', '')], limit=1)

# sale order tax will decide which account will be added to the invoice line
so_tax = self.env['sale.order'].search([('name', '=', invoice.origin)]).amount_tax

if so_tax:
account = self.env['account.account'].search([('id', '=', cg.invoice_line_account_vat.id)])
if cg.invoice_line_account_vat.id:
vals['account_id'] = account.id
else:
account = self.env['account.account'].search([('id', '=', cg.invoice_line_account_no_vat.id)])
if cg.invoice_line_account_vat.id:
vals['account_id'] = account.id

line = super(InvoiceLineExpansion, self).create(vals)

print(line.invoice_line_tax_ids)
print(line.account_id.tax_ids)
line.invoice_line_tax_ids = line.account_id.tax_ids

return line


Avatar
Descartar

Can you please share your code? This way we can find out whether the error lies within it or not.

Autor

Thanks for your reply, I have edited the question with it.

Publicaciones relacionadas Respuestas Vistas Actividad
1
mar 15
7720
1
jun 25
2522
0
nov 23
1413
1
abr 20
3626
1
may 17
5642