Skip to Content
Menu
This question has been flagged
3 Replies
4730 Views

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
Discard

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

Author

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

Related Posts Replies Views Activity
1
Mar 15
6452
0
Nov 23
370
0
Jun 23
1290
1
Apr 20
2423
1
May 17
4335