[FIX] point_of_sale: aml from pos.order.line should have their tax group and children
Having a product on which a group of taxes apply (containing children taxes, obviously) Make a sale Validate the entries Before this commit, the account_move_line created from the pos.order.line had only the group of taxes as their tax_ids Which is inconsistent against what account.invoice do, and against what the generic report tax does After this commit, we imitate what happens on invoices, and the movel line created from the pos.order.line has the children of the group and the group as tax_ids OPW 806089
This commit is contained in:
@@ -197,6 +197,12 @@ class PosOrder(models.Model):
|
||||
return InvoiceLine.sudo().create(inv_line)
|
||||
|
||||
def _create_account_move_line(self, session=None, move=None):
|
||||
def _flatten_tax_and_children(taxes):
|
||||
children = self.env['account.tax']
|
||||
for tax in taxes:
|
||||
children |= _flatten_tax_and_children(tax.children_tax_ids)
|
||||
return taxes + children
|
||||
|
||||
# Tricky, via the workflow, we only have one id in the ids variable
|
||||
"""Create a account move line of order grouped by products or not."""
|
||||
IrProperty = self.env['ir.property']
|
||||
@@ -278,6 +284,9 @@ class PosOrder(models.Model):
|
||||
name = name + ' (' + line.notice + ')'
|
||||
|
||||
# Create a move for the line for the order line
|
||||
# Just like for invoices, a group of taxes must be present on this base line
|
||||
# As well as its children
|
||||
base_line_tax_ids = _flatten_tax_and_children(line.tax_ids_after_fiscal_position).filtered(lambda tax: tax.type_tax_use in ['sale', 'none'])
|
||||
insert_data('product', {
|
||||
'name': name,
|
||||
'quantity': line.qty,
|
||||
@@ -286,7 +295,7 @@ class PosOrder(models.Model):
|
||||
'analytic_account_id': self._prepare_analytic_account(line),
|
||||
'credit': ((amount > 0) and amount) or 0.0,
|
||||
'debit': ((amount < 0) and -amount) or 0.0,
|
||||
'tax_ids': [(6, 0, line.tax_ids_after_fiscal_position.ids)],
|
||||
'tax_ids': [(6, 0, base_line_tax_ids.ids)],
|
||||
'partner_id': partner_id
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user