37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models
|
|
|
|
class PosOrder(models.Model):
|
|
_inherit = 'pos.order'
|
|
|
|
def get_receipt_tax_details(self):
|
|
self.ensure_one()
|
|
tax_map = {}
|
|
for line in self.lines:
|
|
price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
|
line_taxes = line.tax_ids_after_fiscal_position.compute_all(
|
|
price_unit,
|
|
self.currency_id,
|
|
line.qty,
|
|
product=line.product_id,
|
|
partner=self.partner_id
|
|
)
|
|
for tax in line_taxes.get('taxes', []):
|
|
tax_id = tax['id']
|
|
if tax_id not in tax_map:
|
|
tax_map[tax_id] = {
|
|
'name': tax['name'],
|
|
'amount': 0.0,
|
|
'base': 0.0,
|
|
}
|
|
tax_map[tax_id]['amount'] += tax['amount']
|
|
tax_map[tax_id]['base'] += tax['base']
|
|
return list(tax_map.values())
|
|
|
|
def get_order_name(self):
|
|
self.ensure_one()
|
|
name = self.floating_order_name or ""
|
|
if self.is_refund:
|
|
name += " (Refund)"
|
|
return name
|