Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
1662 มุมมอง

how can i calcualte  amount_taxed and amount_taxed  in and  stock_picking

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Try this code

from odoo import models, fields, api


class StockPicking(models.Model):

    _inherit = 'stock.picking'


    amount_taxed = fields.Monetary(string="Amount Taxed", compute='_compute_amount_taxed', store=True)


    @api.depends('move_ids.product_id', 'move_ids.move_line_ids.move_line_tax_ids')

    def _compute_amount_taxed(self):

        for picking in self:

            taxed_amount = 0.0

            for move in picking.move_ids:

                for move_line in move.move_line_ids:

                    # Sum up the taxes for each move line

                    for tax in move_line.move_line_tax_ids:

                        taxed_amount += tax.amount


            picking.amount_taxed = taxed_amount


Hope it helps


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

i get 

ValueError: Field stock.picking.amount_untaxed cannot find dependency 'move_ids' on model 'stock.picking'.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 24
2433
1
เม.ย. 24
2277
2
ก.ย. 24
1609
2
ก.ค. 24
2246
0
พ.ค. 24
993