Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] sale_order_taxes 9.0 #1106

Open
wants to merge 1 commit into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sale_order_taxes/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"security/ir.model.access.csv",
"views/sale_order_view.xml",
],
'installable': False,
'installable': True,
}
19 changes: 6 additions & 13 deletions sale_order_taxes/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class SaleOrderTax(models.Model):
sale_order = fields.Many2one(comodel_name='sale.order',
string='Sale Order', ondelete='cascade')
name = fields.Char(string='Tax Description', required=True)
base = fields.Float(string='Base', digits=dp.get_precision('Account'))
amount = fields.Float(string='Amount', digits=dp.get_precision('Account'))
sequence = fields.Integer(
string='Sequence',
Expand All @@ -49,29 +48,24 @@ def compute(self, order):
for line in order.order_line:
taxes = line.tax_id.compute_all(
(line.price_unit * (1 - (line.discount or 0.0) / 100.0)),
line.product_uom_qty, line.product_id,
order.partner_id)['taxes']
currency=currency,
quantity=line.product_uom_qty,
product=line.product_id,
partner=order.partner_id)['taxes']
for tax in taxes:
val = {
'order': order.id,
'name': tax['name'],
'amount': tax['amount'],
'base': currency.round(tax['price_unit'] *
line.product_uom_qty),
'sequence': tax['sequence'],
'base_code_id': tax['base_code_id'],
'tax_code_id': tax['tax_code_id'],
'tax_id': tax['id'],
}
key = (val['tax_code_id'], val['base_code_id'])
key = val['tax_id']
if key not in tax_grouped:
tax_grouped[key] = val
else:
tax_grouped[key]['base'] += val['base']
tax_grouped[key]['amount'] += val['amount']
# tax_grouped[key]['base_amount'] += val['base_amount']
# tax_grouped[key]['tax_amount'] += val['tax_amount']
for t in tax_grouped.values():
t['base'] = currency.round(t['base'])
t['amount'] = currency.round(t['amount'])
return tax_grouped

Expand All @@ -85,7 +79,6 @@ def _calc_taxes(self):
'sale_order': tax['order'],
'sequence': tax['sequence'],
'name': tax['name'],
'base': tax['base'],
'amount': tax['amount']})
return True

Expand Down
1 change: 0 additions & 1 deletion sale_order_taxes/views/sale_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<field name="taxes" nolabel="1" >
<tree>
<field name="name" />
<field name="base" />
<field name="amount" />
</tree>
</field>
Expand Down