Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
1521 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang

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

Post Terkait Replies Tampilan Aktivitas
0
Sep 24
843
1
Agu 24
2307
2
Apr 24
1611
1
Apr 24
2154
2
Apr 20
2941