Commit 5147cc98 by 夏超

[fix] 修改后台委外发料数据

parent 2172067b
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError, UserError
class InheritWorkOrder(models.Model): class InheritWorkOrder(models.Model):
...@@ -58,3 +58,54 @@ class InheritWorkOrder(models.Model): ...@@ -58,3 +58,54 @@ class InheritWorkOrder(models.Model):
else: else:
allow_qty, default_qty = super(InheritWorkOrder, self)._get_wo_allow_qty() allow_qty, default_qty = super(InheritWorkOrder, self)._get_wo_allow_qty()
return allow_qty, default_qty return allow_qty, default_qty
def _get_bom_transportation_line_vals(self, record, bom):
"""
获取BOM发料内容
:return:
"""
return {
'product_index': record.product_id.id,
'partner_id': record.entrust_customer.id,
'product_id': bom.product_id.id,
"qty": bom.qty * record.entrust_qty,
'wo_id': record.id,
'origin_work_id': record.id
}
def confirm_transportation_material(self):
product_list = []
# 检验工单是否符合发料条件
for i in self:
# 检查自由报工
if i.env.user.company_id.freedom_work != "允许":
i._check_freedom_work(i.finish_qty)
if not i.entrust_customer:
raise UserError('请选择委外客户!')
if i.entrust_state == '已发料':
raise UserError('存在已发料的委外工单,请重新选择!')
# 检测是否含有委外出库的调拨类型
type_id = self.env['roke.mes.stock.picking.type'].search([('index', '=', 'WW/OUT/')], limit=1)
if not type_id:
raise UserError('请前往仓库管理->作业类型,配置标识为 WW/OUT/ 的出库类型的委外出库!')
# 数据创建展示
for record in self:
for bom in record.routing_line_id.p_bom_ids:
product_list.append((0, 0, self._get_bom_transportation_line_vals(record, bom)))
res = self.env["transportation.product.info.wizard"].create({
"picking_type_id": type_id.id,
"src_location_id": type_id.src_location_id.id,
"dest_location_id": type_id.dest_location_id.id,
"entrust_ids": self.ids,
"move_line_ids": product_list
})
return {
'name': '发料',
'type': 'ir.actions.act_window',
'res_model': 'transportation.product.info.wizard',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
'res_id': res.id,
'context': {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment