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

hello i want to crreat function that calculate amount_taxed and amount_untaxed

i did this function  but  i cant get tax add to function any solution


class StockPicking(models.Model):
_inherit = 'stock.picking'

amount_untaxed = fields.Float(string='Untaxed Amount', compute='_compute_amounts', store=True)
amount_tax = fields.Float(string='Taxes')
amount_total = fields.Float(string='Total', compute='_compute_amounts', store=True)

@api.depends('move_lines.price_unit', 'move_lines.product_uom_qty')
def _compute_amounts(self):
for picking in self:
amount_untaxed = 0.0
amount_tax = 0.0
amount_total = 0.0
for move in picking.move_lines:

price_unit = move.price_unit
quantity = move.product_uom_qty

amount_total += price_unit * quantity
picking.amount_total = amount_total


Avatar
Discard
Best Answer

Hi Mohammed please see below link,
https://www.odoo.com/forum/help-1/calcule-amount-taxed-in-stock-picking-236712
Hope this will help.

Avatar
Discard
Best Answer

Hi mohamed el boukhari el kassmi,


You can try this code for all tax values in stock picking.

Please find code in comment.

Hope this answer helps you.

Thanks & Regards,
Email: odoo@aktivsoftware.com     

Skype: kalpeshmaheshwari

Avatar
Discard

Please find code here :-

EX:

class CustomStockPicking(models.Model):

_inherit = 'stock.picking'

amount_untaxed = fields.Monetary(string='Untaxed Amount', compute='_compute_amount', store=True)
amount_tax = fields.Monetary(string='Tax Amount', compute='_compute_amount', store=True)
amount_total = fields.Monetary(string='Total Amount', compute='_compute_amount', store=True)

@api.depends('move_lines.amount_untaxed', 'move_lines.amount_tax')
def _compute_amount(self):
for picking in self:
untaxed_amount = sum(picking.move_lines.filtered(lambda m: not m.product_id.taxable).mapped('amount_untaxed'))
tax_amount = sum(picking.move_lines.filtered(lambda m: m.product_id.taxable).mapped('amount_tax'))
picking.amount_untaxed = untaxed_amount
picking.amount_tax = tax_amount
picking.amount_total = untaxed_amount + tax_amount

Related Posts Replies Views Activity
0
Sep 24
759
1
Aug 24
2230
2
Apr 24
1536
1
Apr 24
2072
2
Apr 20
2851