Skip to Content
Menú
This question has been flagged
2 Respostes
1496 Vistes

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
Descartar
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
Descartar
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
Descartar

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 Respostes Vistes Activitat
0
de set. 24
828
1
d’ag. 24
2297
2
d’abr. 24
1597
1
d’abr. 24
2139
2
d’abr. 20
2920