Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
1431 Vistas

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
Mejor respuesta

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
Mejor respuesta

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

Publicaciones relacionadas Respuestas Vistas Actividad
0
sept 24
759
1
ago 24
2229
2
abr 24
1536
1
abr 24
2071
2
abr 20
2851