Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1506 Widoki

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


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
0
wrz 24
836
1
sie 24
2301
2
kwi 24
1602
1
kwi 24
2142
2
kwi 20
2930