odoo - 将字段自定义从采购订单行复制到odoo中的库存移动
问题描述
我正在使用 odoo 13。我在采购订单行中有一个自定义字段权重。我想将此字段的值复制到库存移动中的自定义字段。我知道要将字段的值从销售订单转移到库存移动,我可以通过以下方式进行。
class StockMoveLine(models.Model):
_inherit = 'stock.move'
weight = fields.Float(
compute='_compute_weight' )
def _compute_weight(self):
for move in self:
if not (move.picking_id and move.picking_id.group_id):
continue
picking = move.picking_id
sale_order = self.env['sale.order'].sudo().search([
('procurement_group_id', '=', picking.group_id.id)], limit=1)
# print(picking)
if sale_order:
for line in sale_order.order_line:
if line.product_id.id != move.product_id.id:
continue
move.update({
'weight': line.weight,
})
continue
else:
# move.update({
# 'weight': move.weight,
# })
但是,我发现自己陷入了从购买到库存转移的其他领域
解决方案
您可以使用链接到的purchase_line_id
字段stock.move
purchase.order.line
代码 -库存移动中的 PoL 参考
推荐阅读
- pandas - Pandas.Series.mode 最终会有多行结果。如何解决?
- applescript - 可组织的文件目录,将更改应用于不同位置的原始文件
- swift - 当一个物体撞到另一个物体时,如何让它改变颜色?
- javascript - 为 javascript 占位符转义 jinja 模板
- python - 将 json 值/字典映射到不同的函数
- java - 当我使用 JGit 库 DiffFormatter 时,为什么会捕获 IOException?
- machine-learning - scipy.optimize.minimize 找不到最小二乘解决方案
- html - 如何从 Angular 中的另一个组件访问导航栏 css 属性
- redis - 与中央数据库同步的内存数据库
- tensorflow - TensorFlow libcublas 10.0 问题