【发布时间】:2020-04-02 11:22:38
【问题描述】:
我已经为下面的代码工作了几天,但仍然无法正常工作。我打算做的是当在产品创建部分选择一种原材料产品类型(自定义字段)时,将选择购买路线。另一方面,选择“Finish Good”,将选择制造和 MTO 路线。下面的代码做了一半,因为当从 Raw-Material 切换到 Finish Good 时,它不会清除之前选择的值。之前的填充值仍然存在。请帮忙!非常感谢。
@api.onchange('custom_product_type')
def _onchange_custom_product_type (self):
if self.custom_product_type:
self.warehouse = self.env.ref ('stock.warehouse0')
route_manufacture = self.env.ref ('stock.warehouse0'). manufacture_pull_id.route_id.id
route_mto = self.env.ref ('stock.warehouse0'). mto_pull_id.route_id.id
buy_route = self.env.ref ('stock.warehouse0'). buy_pull_id.route_id.id
if self.custom_product_type == 'RM':
self.sale_ok = False
self.purchase_ok = True
self.update ({'route_ids': [(6, 0, [buy_route])]})
elif self.custom_product_type == 'FG' or self.custom_product_type == 'HG':
self.sale_ok = True
self.purchase_ok = False
self.update ({'route_ids': [(6, 0, [route_manufacture, route_mto])]})
【问题讨论】:
标签: odoo