โพสต์ โดย kitcle » เสาร์ 07 ก.ค. 2018 3:30 am
ในระบบ odoo core นั้นระบบจะให้ค่า forecast ลดลง เมื่อทำการ confirm Sale order
แต่ความต้องการของคุณ คือ ใช้ตอนเลือกสินค้าเป็นตัวกำหนดการ reserve เพื่อไปลดค่า forecast ซึ่งผมว่าไม่ make sense
แต่ถึงกระนั้น ก็สามารถทำได้ เพราะบางองค์กรจะจองสินค้าทันทีเมื่อเกิด Quotation
โค้ด: เลือกทั้งหมด
@api.multi
@api.onchange('product_id', 'route_id')
def _get_product_info(self):
for line in self:
proc = self.env['procurement.rule'].search([('route_id', '=', line.route_id.id)], limit=1)
sol = self.env['sale.order.line'].search([('product_id', '=', line.product_id.id),('state', '=', ['draft','approve','sent','pending']),('route_id', '=', proc[0].route_id.id)])
sum_qo = sum(x.product_uom_qty for x in sol)
line.qty_available = line.product_id.with_context({'location' : proc.location_src_id.id}).qty_available
incoming_qty = line.product_id.with_context({'location' : proc.location_src_id.id}).incoming_qty
line.qty_virtual = line.product_id.with_context({'location' : proc.location_src_id.id}).virtual_available - incoming_qty - sum_qo
line.outgoing_qty = line.product_id.with_context({'location' : proc.location_src_id.id}).outgoing_qty
line.qoutation_qty = sum_qo
ในระบบ odoo core นั้นระบบจะให้ค่า forecast ลดลง เมื่อทำการ confirm Sale order
แต่ความต้องการของคุณ คือ ใช้ตอนเลือกสินค้าเป็นตัวกำหนดการ reserve เพื่อไปลดค่า forecast ซึ่งผมว่าไม่ make sense
แต่ถึงกระนั้น ก็สามารถทำได้ เพราะบางองค์กรจะจองสินค้าทันทีเมื่อเกิด Quotation
[code]
@api.multi
@api.onchange('product_id', 'route_id')
def _get_product_info(self):
for line in self:
proc = self.env['procurement.rule'].search([('route_id', '=', line.route_id.id)], limit=1)
sol = self.env['sale.order.line'].search([('product_id', '=', line.product_id.id),('state', '=', ['draft','approve','sent','pending']),('route_id', '=', proc[0].route_id.id)])
sum_qo = sum(x.product_uom_qty for x in sol)
line.qty_available = line.product_id.with_context({'location' : proc.location_src_id.id}).qty_available
incoming_qty = line.product_id.with_context({'location' : proc.location_src_id.id}).incoming_qty
line.qty_virtual = line.product_id.with_context({'location' : proc.location_src_id.id}).virtual_available - incoming_qty - sum_qo
line.outgoing_qty = line.product_id.with_context({'location' : proc.location_src_id.id}).outgoing_qty
line.qoutation_qty = sum_qo
[/code]