[MERGE] forward port branch saas-15 up to 0401a7349e

This commit is contained in:
Christophe Simonis
2018-02-12 11:46:00 +01:00
2 changed files with 11 additions and 2 deletions
@@ -135,7 +135,7 @@
<th>Net Imposable</th>
<th>Plafond s.s.</th>
<th></th>
<th>Coût Global Salarié</th>
<th>Total versé par l'employeur</th>
</tr>
</thead>
<tbody>
+10 -1
View File
@@ -199,6 +199,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']
@@ -280,6 +286,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,
@@ -288,7 +297,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
})