summaryrefslogtreecommitdiff
path: root/addons/account/models/account.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/account/models/account.py')
-rw-r--r--addons/account/models/account.py71
1 files changed, 31 insertions, 40 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index da381195dd2..cb7ce2dd8ac 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -553,8 +553,6 @@ class AccountJournal(models.Model):
domain=[('deprecated', '=', False)], help="It acts as a default account for debit amount")
update_posted = fields.Boolean(string='Allow Cancelling Entries',
help="Check this box if you want to allow the cancellation the entries related to this journal or of the invoice related to this journal")
- group_invoice_lines = fields.Boolean(string='Group Invoice Lines',
- help="If this box is checked, the system will try to group the accounting lines when generating them from invoices.")
sequence_id = fields.Many2one('ir.sequence', string='Entry Sequence',
help="This field contains the information related to the numbering of the journal entries of this journal.", required=True, copy=False)
refund_sequence_id = fields.Many2one('ir.sequence', string='Credit Note Entry Sequence',
@@ -738,7 +736,7 @@ class AccountJournal(models.Model):
if self.alias_id:
self.alias_id.write(alias_values)
else:
- self.alias_id = self.env['mail.alias'].with_context(alias_model_name='account.invoice',
+ self.alias_id = self.env['mail.alias'].with_context(alias_model_name='account.move',
alias_parent_model_name='account.journal').create(alias_values)
if vals.get('alias_name'):
@@ -1179,17 +1177,6 @@ class AccountTax(models.Model):
if self.price_include:
self.include_base_amount = True
- def get_grouping_key(self, invoice_tax_val):
- """ Returns a string that will be used to group account.invoice.tax sharing the same properties"""
- self.ensure_one()
- return str(invoice_tax_val['tax_id']) + '-' + \
- str(invoice_tax_val.get('tax_repartition_line_id')) + '-' + \
- str(invoice_tax_val['account_id']) + '-' + \
- str(invoice_tax_val['account_analytic_id']) + '-' + \
- str(invoice_tax_val.get('analytic_tag_ids', [])) + '-' + \
- str(invoice_tax_val.get('tax_ids') or []) + '-' + \
- str(invoice_tax_val.get('tag_ids') or [])
-
def _compute_amount(self, base_amount, price_unit, quantity=1.0, product=None, partner=None):
""" Returns the amount of a single tax. base_amount is the actual amount on which the tax is applied, which is
price_unit * quantity eventually affected by previous taxes (if tax is include_base_amount XOR price_include)
@@ -1210,7 +1197,7 @@ class AccountTax(models.Model):
else:
return quantity * self.amount
- price_include = self._context['force_price_include'] if 'force_price_include' in self._context else self.price_include
+ price_include = self._context.get('force_price_include', self.price_include)
# base * (1 + tax_amount) = new_base
if self.amount_type == 'percent' and not price_include:
@@ -1254,12 +1241,15 @@ class AccountTax(models.Model):
return rep_lines.filtered(lambda x: x.repartition_type == repartition_type).mapped('tag_ids')
@api.multi
- def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False):
+ def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, partner=None, is_refund=False, handle_price_include=True):
""" Returns all information required to apply taxes (in self + their children in case of a tax group).
We consider the sequence of the parent for group of taxes.
Eg. considering letters as taxes and alphabetic order as sequence :
[G, B([A, D, F]), E, C] will be computed as [A, D, F, C, E, G]
+ 'handle_price_include' is used when we need to ignore all tax included in price. If False, it means the
+ amount passed to this method will be considered as the base of all computations.
+
RETURN: {
'total_excluded': 0.0, # Total without taxes
'total_included': 0.0, # Total with taxes
@@ -1362,28 +1352,29 @@ class AccountTax(models.Model):
incl_fixed_amount = incl_percent_amount = incl_division_amount = 0
# Store the tax amounts we compute while searching for the total_excluded
cached_tax_amounts = {}
- for tax in reversed(taxes):
- if tax.include_base_amount:
- base = recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount)
- incl_fixed_amount = incl_percent_amount = incl_division_amount = 0
- store_included_tax_total = True
- if tax.price_include:
- if tax.amount_type == 'percent':
- incl_percent_amount += tax.amount
- elif tax.amount_type == 'division':
- incl_division_amount += tax.amount
- elif tax.amount_type == 'fixed':
- incl_fixed_amount += quantity * tax.amount
- else:
- # tax.amount_type == other (python)
- tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner)
- incl_fixed_amount += tax_amount
- # Avoid unecessary re-computation
- cached_tax_amounts[i] = tax_amount
- if store_included_tax_total:
- total_included_checkpoints[i] = base
- store_included_tax_total = False
- i -= 1
+ if handle_price_include:
+ for tax in reversed(taxes):
+ if tax.include_base_amount:
+ base = recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount)
+ incl_fixed_amount = incl_percent_amount = incl_division_amount = 0
+ store_included_tax_total = True
+ if tax.price_include:
+ if tax.amount_type == 'percent':
+ incl_percent_amount += tax.amount
+ elif tax.amount_type == 'division':
+ incl_division_amount += tax.amount
+ elif tax.amount_type == 'fixed':
+ incl_fixed_amount += quantity * tax.amount
+ else:
+ # tax.amount_type == other (python)
+ tax_amount = tax._compute_amount(base, price_unit, quantity, product, partner)
+ incl_fixed_amount += tax_amount
+ # Avoid unecessary re-computation
+ cached_tax_amounts[i] = tax_amount
+ if store_included_tax_total:
+ total_included_checkpoints[i] = base
+ store_included_tax_total = False
+ i -= 1
total_excluded = recompute_base(base, incl_fixed_amount, incl_percent_amount, incl_division_amount)
@@ -1438,8 +1429,8 @@ class AccountTax(models.Model):
'price_include': tax.price_include,
'tax_exigibility': tax.tax_exigibility,
'tax_repartition_line_id': repartition_line.id,
- 'tag_ids': [(6, False, (repartition_line.tag_ids + subsequent_tags).ids)],
- 'tax_ids': [(6, False, subsequent_taxes.ids)]
+ 'tag_ids': (repartition_line.tag_ids + subsequent_tags).ids,
+ 'tax_ids': subsequent_taxes.ids,
})
total_amount += line_amount