| 1 |
|
| 2 |
from odoo import models |
| 3 |
|
| 4 |
|
| 5 |
class AccountMoveLine(models.Model): |
| 6 |
_inherit = 'account.move.line' |
| 7 |
|
| 8 |
def _l10n_ar_prices_and_taxes(self): |
| 9 |
self.ensure_one() |
| 10 |
invoice = self.move_id |
| 11 |
include_vat = invoice._l10n_ar_include_vat() |
| 12 |
|
| 13 |
AccountTax = self.env['account.tax'] |
| 14 |
base_line = invoice._prepare_product_base_line_for_taxes_computation(self) |
| 15 |
if include_vat: |
| 16 |
base_line['tax_ids'] = self.tax_ids.filtered('tax_group_id.l10n_ar_vat_afip_code') |
| 17 |
AccountTax._add_tax_details_in_base_line(base_line, self.company_id, rounding_method='round_globally') |
| 18 |
|
| 19 |
tax_details = base_line['tax_details'] |
| 20 |
discount = base_line['discount'] |
| 21 |
price_unit = base_line['price_unit'] |
| 22 |
quantity = base_line['quantity'] |
| 23 |
if include_vat: |
| 24 |
raw_total = tax_details['raw_total_included_currency'] |
| 25 |
else: |
| 26 |
raw_total = tax_details['raw_total_excluded_currency'] |
| 27 |
|
| 28 |
if discount == 100.0: |
| 29 |
price_subtotal_before_discount = price_unit * quantity |
| 30 |
else: |
| 31 |
price_subtotal_before_discount = raw_total / (1 - discount / 100.0) |
| 32 |
|
| 33 |
if quantity: |
| 34 |
price_unit = price_subtotal_before_discount / quantity |
| 35 |
price_net = raw_total / quantity |
| 36 |
else: |
| 37 |
price_unit = 0.0 |
| 38 |
price_net = 0.0 |
| 39 |
|
| 40 |
return { |
| 41 |
'price_unit': price_unit, |
| 42 |
'price_subtotal': invoice.currency_id.round(raw_total), |
| 43 |
'price_net': price_net, |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
def get_column_to_exclude_for_colspan_calculation(self, taxes=None): |
| 48 |
return super().get_column_to_exclude_for_colspan_calculation(taxes) |