Skip to Content
Menu
This question has been flagged
2 Replies
5573 Views

Code

Error​   

i just need to minus value from price_subtotal else odoo do its current behavior 

but with my code tax calculation going wrong ....

Any best solution you suggest 


Avatar
Discard

how you calculate tax amount?is it tax of subtotal-received in advance?

Best Answer

Hello,

Please try this code,

@api.depends('product_uom_qty', 'discount', 'price_unit', 'tax_id','receive_in_advance')
def _compute_amount(self):
    """Compute the amounts of the SO line."""
    for line in self:
        price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
        if line.product_uom_qty and line.receive_in_advance:
            price = price - (line.receive_in_advance/line.product_uom_qty)
        taxes = line.tax_id.compute_all(price, line.order_id.currency_id, line.product_uom_qty, product=line.product_id, partner=line.order_id.partner_shipping_id)
        line.update({
            'price_tax': sum(t.get('amount', 0.0) for t in taxes.get('taxes', [])),
            'price_total': taxes['total_included'],
            'price_subtotal': taxes['total_excluded'],
        })                          

If you use UOM, then please change the code accordingly.

Hope this will help you,

Thanks

Avatar
Discard
Related Posts Replies Views Activity
0
Sep 24
122
3
Aug 24
528
0
Feb 24
263
0
Feb 24
157
1
Jan 24
1325