Accept Merge Request #1267: (feature/优化工单 -> develop)
Merge Request: 优化工单 Created By: @杨金灵 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @杨金灵 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1267
This commit is contained in:
@@ -1101,67 +1101,19 @@ class MrpProduction(models.Model):
|
|||||||
('is_subcontract', '=', True)])
|
('is_subcontract', '=', True)])
|
||||||
if scarp_process_parameter_workorder:
|
if scarp_process_parameter_workorder:
|
||||||
production_programming = self.env['mrp.production'].search(
|
production_programming = self.env['mrp.production'].search(
|
||||||
[('programming_no', '=', self.programming_no)], order='name asc')
|
[('programming_no', '=', self.programming_no), ('id', '!=', productions.id)], order='name asc')
|
||||||
production_list = [production.name for production in production_programming]
|
production_list = [production.name for production in production_programming]
|
||||||
purchase_orders = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
purchase_orders = self.env['purchase.order'].search([('origin', 'ilike', ','.join(production_list))])
|
||||||
for purchase_item in purchase_orders.order_line:
|
for purchase_item in purchase_orders.order_line:
|
||||||
for process_item in scarp_process_parameter_workorder:
|
for process_item in scarp_process_parameter_workorder:
|
||||||
if purchase_item.product_id.categ_type == '表面工艺':
|
if purchase_item.product_id.categ_type == '表面工艺':
|
||||||
if purchase_item.product_id.server_product_process_parameters_id == process_item.surface_technics_parameters_id:
|
if purchase_item.product_id.server_product_process_parameters_id == process_item.surface_technics_parameters_id:
|
||||||
print(purchase_orders.find(productions.name))
|
print(purchase_orders.origin.find(productions.name))
|
||||||
if purchase_orders.find(productions.name) == -1:
|
if purchase_orders.origin.find(productions.name) == -1:
|
||||||
purchase_orders.origin += productions.name
|
purchase_orders.origin += ',' + productions.name
|
||||||
if item['is_reprogramming'] is False:
|
if item['is_reprogramming'] is False:
|
||||||
productions._create_workorder(item)
|
productions._create_workorder(item)
|
||||||
productions.programming_state = '已编程'
|
productions.programming_state = '已编程'
|
||||||
for production_item in productions:
|
|
||||||
process_parameter_workorder = self.env['mrp.workorder'].search(
|
|
||||||
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production_item.id),
|
|
||||||
('is_subcontract', '=', True)])
|
|
||||||
if process_parameter_workorder:
|
|
||||||
is_pick = False
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
|
|
||||||
for i in range(len(sorted_workorders) - 1):
|
|
||||||
if m == 0:
|
|
||||||
is_pick = False
|
|
||||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
|
||||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
|
||||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
|
||||||
if sorted_workorders[i] not in consecutive_workorders:
|
|
||||||
consecutive_workorders.append(sorted_workorders[i])
|
|
||||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
|
||||||
m += 1
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
|
||||||
production_item)
|
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
|
||||||
is_pick = True
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
|
|
||||||
if is_pick is False:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
|
||||||
production_item)
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
|
||||||
production_item)
|
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
|
||||||
is_pick = True
|
|
||||||
consecutive_workorders = []
|
|
||||||
m = 0
|
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
|
||||||
production_item)
|
|
||||||
if is_pick is False and m == 0:
|
|
||||||
if len(sorted_workorders) == 1:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production_item)
|
|
||||||
else:
|
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
|
||||||
production_item)
|
|
||||||
else:
|
else:
|
||||||
productions.programming_state = '编程中'
|
productions.programming_state = '编程中'
|
||||||
return productions
|
return productions
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
('cancel', '取消')], string='Status',
|
('cancel', '取消')], string='Status',
|
||||||
compute='_compute_state', store=True,
|
compute='_compute_state', store=True,
|
||||||
default='pending', copy=False, readonly=True, recursive=True, index=True, tracking=True)
|
default='pending', copy=False, readonly=True, recursive=True, index=True, tracking=True)
|
||||||
|
|
||||||
# state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')], tracking=True)
|
# state = fields.Selection(selection_add=[('to be detected', "待检测"), ('rework', '返工')], tracking=True)
|
||||||
|
|
||||||
@api.depends('production_id.manual_quotation')
|
@api.depends('production_id.manual_quotation')
|
||||||
@@ -183,17 +184,12 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if order.routing_type == '表面工艺':
|
if order.routing_type == '表面工艺':
|
||||||
production_programming = self.env['mrp.production'].search(
|
production_programming = self.env['mrp.production'].search(
|
||||||
[('programming_no', '=', order.production_id.programming_no)], order='name asc')
|
[('programming_no', '=', order.production_id.programming_no)], order='name asc')
|
||||||
|
production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
|
||||||
production_list = [production.name for production in production_programming]
|
production_list = [production.name for production in production_programming]
|
||||||
purchase = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
purchase = self.env['purchase.order'].search([('origin', '=', ','.join(production_list))])
|
||||||
for line in purchase.order_line:
|
for line in purchase.order_line:
|
||||||
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id and line.product_qty == len(
|
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id and line.product_qty == len(
|
||||||
production_programming):
|
production_no_remanufacture):
|
||||||
# server_product = self.env['product.template'].search(
|
|
||||||
# [('server_product_process_parameters_id', '=', pp.id),
|
|
||||||
# ('detailed_type', '=', 'service')])
|
|
||||||
# purchase_order_line = self.env['purchase.order.line'].search(
|
|
||||||
# [('product_id', '=', server_product.id), ('product_qty', '=', len(production_programming))])
|
|
||||||
# if purchase_order_line:
|
|
||||||
order.surface_technics_purchase_count = len(purchase)
|
order.surface_technics_purchase_count = len(purchase)
|
||||||
else:
|
else:
|
||||||
order.surface_technics_purchase_count = 0
|
order.surface_technics_purchase_count = 0
|
||||||
@@ -243,6 +239,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
store=True, compute='_compute_tool_state')
|
store=True, compute='_compute_tool_state')
|
||||||
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
|
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
|
||||||
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
reserved_duration = fields.Float('预留时长', default=30, tracking=True)
|
||||||
|
|
||||||
@api.depends('cnc_ids.tool_state')
|
@api.depends('cnc_ids.tool_state')
|
||||||
def _compute_tool_state_remark(self):
|
def _compute_tool_state_remark(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
@@ -651,7 +648,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# 拼接工单对象属性值
|
# 拼接工单对象属性值
|
||||||
def json_workorder_str(self, k, production, route, item):
|
def json_workorder_str(self, k, production, route, item):
|
||||||
# 计算预计时长duration_expected
|
# 计算预计时长duration_expected
|
||||||
routing_types = ['切割', '装夹预调', 'CNC加工','解除装夹']
|
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
||||||
if route.routing_type in routing_types:
|
if route.routing_type in routing_types:
|
||||||
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
[('name', '=', route.routing_type)])
|
[('name', '=', route.routing_type)])
|
||||||
@@ -704,7 +701,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
item),
|
item),
|
||||||
# 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
|
# 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
|
||||||
# production)
|
# production)
|
||||||
'reserved_duration': reserved_duration,
|
'reserved_duration': reserved_duration,
|
||||||
}]
|
}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
@@ -1169,8 +1166,9 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
if record.routing_type == '装夹预调':
|
if record.routing_type == '装夹预调':
|
||||||
if not record.rfid_code and record.is_rework is False:
|
if not record.rfid_code and record.is_rework is False:
|
||||||
raise UserError("请扫RFID码进行绑定")
|
raise UserError("请扫RFID码进行绑定")
|
||||||
if not record.material_center_point and record.X_deviation_angle > 0:
|
if record.is_rework is False:
|
||||||
raise UserError("坯料中心点为空或X偏差角度小于等于0")
|
if not record.material_center_point or record.X_deviation_angle <= 0:
|
||||||
|
raise UserError("请对前置三元检测定位参数进行计算定位")
|
||||||
record.process_state = '待加工'
|
record.process_state = '待加工'
|
||||||
# record.write({'process_state': '待加工'})
|
# record.write({'process_state': '待加工'})
|
||||||
record.production_id.process_state = '待加工'
|
record.production_id.process_state = '待加工'
|
||||||
|
|||||||
@@ -288,28 +288,46 @@ class StockRule(models.Model):
|
|||||||
# 为同一个product_id创建一个生产订单名称列表
|
# 为同一个product_id创建一个生产订单名称列表
|
||||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||||
for production_item in productions:
|
for production_item in productions:
|
||||||
|
production_programming = self.env['mrp.production'].search(
|
||||||
|
[('product_id.id', '=', production_item.product_id.id),
|
||||||
|
('origin', '=', production_item.origin)],
|
||||||
|
limit=1, order='id asc')
|
||||||
if production_item.product_id.id in product_id_to_production_names:
|
if production_item.product_id.id in product_id_to_production_names:
|
||||||
if production_item.product_id.model_process_parameters_ids:
|
if not production_programming.programming_no:
|
||||||
is_purchase = False
|
if production_item.product_id.model_process_parameters_ids:
|
||||||
sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids,
|
is_purchase = False
|
||||||
key=lambda w: w.id)
|
sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids,
|
||||||
|
key=lambda w: w.id)
|
||||||
|
|
||||||
consecutive_process_parameters = []
|
consecutive_process_parameters = []
|
||||||
m = 0
|
m = 0
|
||||||
for i in range(len(sorted_process_parameters) - 1):
|
for i in range(len(sorted_process_parameters) - 1):
|
||||||
if m == 0:
|
if m == 0:
|
||||||
is_purchase = False
|
is_purchase = False
|
||||||
if self.env['product.template']._get_process_parameters_product(
|
if self.env['product.template']._get_process_parameters_product(
|
||||||
sorted_process_parameters[i]).partner_id == self.env[
|
sorted_process_parameters[i]).partner_id == self.env[
|
||||||
'product.template']._get_process_parameters_product(sorted_process_parameters[
|
'product.template']._get_process_parameters_product(sorted_process_parameters[
|
||||||
i + 1]).partner_id and \
|
i + 1]).partner_id and \
|
||||||
sorted_process_parameters[i].gain_way == '外协':
|
sorted_process_parameters[i].gain_way == '外协':
|
||||||
if sorted_process_parameters[i] not in consecutive_process_parameters:
|
if sorted_process_parameters[i] not in consecutive_process_parameters:
|
||||||
consecutive_process_parameters.append(sorted_process_parameters[i])
|
consecutive_process_parameters.append(sorted_process_parameters[i])
|
||||||
consecutive_process_parameters.append(sorted_process_parameters[i + 1])
|
consecutive_process_parameters.append(sorted_process_parameters[i + 1])
|
||||||
m += 1
|
m += 1
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
|
production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
|
if sorted_process_parameters[i] in consecutive_process_parameters:
|
||||||
|
is_purchase = True
|
||||||
|
consecutive_process_parameters = []
|
||||||
|
m = 0
|
||||||
|
# 当前面的连续外协采购单生成再生成当前外协采购单
|
||||||
|
if is_purchase is False:
|
||||||
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
|
production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
production_item,
|
production_item,
|
||||||
@@ -318,39 +336,22 @@ class StockRule(models.Model):
|
|||||||
is_purchase = True
|
is_purchase = True
|
||||||
consecutive_process_parameters = []
|
consecutive_process_parameters = []
|
||||||
m = 0
|
m = 0
|
||||||
# 当前面的连续外协采购单生成再生成当前外协采购单
|
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||||
if is_purchase is False:
|
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if sorted_process_parameters[i] in consecutive_process_parameters:
|
|
||||||
is_purchase = True
|
|
||||||
consecutive_process_parameters = []
|
|
||||||
m = 0
|
|
||||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
if is_purchase is False and m == 0:
|
|
||||||
if len(sorted_process_parameters) == 1:
|
|
||||||
self.env['purchase.order'].get_purchase_order(sorted_process_parameters,
|
|
||||||
production_item,
|
|
||||||
product_id_to_production_names)
|
|
||||||
else:
|
|
||||||
self.env['purchase.order'].get_purchase_order(sorted_process_parameters[i],
|
|
||||||
production_item,
|
production_item,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
|
if is_purchase is False and m == 0:
|
||||||
|
if len(sorted_process_parameters) == 1:
|
||||||
|
self.env['purchase.order'].get_purchase_order(sorted_process_parameters,
|
||||||
|
production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
|
else:
|
||||||
|
self.env['purchase.order'].get_purchase_order(sorted_process_parameters[i],
|
||||||
|
production_item,
|
||||||
|
product_id_to_production_names)
|
||||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||||
if not production_item.programming_no:
|
if not production_item.programming_no:
|
||||||
production_programming = self.env['mrp.production'].search(
|
|
||||||
[('product_id.id', '=', production_item.product_id.id),
|
|
||||||
('origin', '=', production_item.origin)],
|
|
||||||
limit=1, order='id asc')
|
|
||||||
if not production_programming.programming_no:
|
if not production_programming.programming_no:
|
||||||
production_item.fetchCNC(
|
production_item.fetchCNC(
|
||||||
', '.join(product_id_to_production_names[production_item.product_id.id]))
|
', '.join(product_id_to_production_names[production_item.product_id.id]))
|
||||||
@@ -544,7 +545,7 @@ class StockPicking(models.Model):
|
|||||||
|
|
||||||
# 设置外协出入单的名称
|
# 设置外协出入单的名称
|
||||||
def _get_name_Res(self, rescode):
|
def _get_name_Res(self, rescode):
|
||||||
last_picking = self.sudo().search([('name', 'like', rescode)], order='create_date desc,id desc', limit=1)
|
last_picking = self.sudo().search([('name', 'ilike', rescode)], order='create_date desc,id desc', limit=1)
|
||||||
if not last_picking:
|
if not last_picking:
|
||||||
num = "%04d" % 1
|
num = "%04d" % 1
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -437,6 +437,12 @@
|
|||||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||||
<button name="action_cancel" type="object" string="取消" groups="sf_base.group_sf_mrp_user"/>
|
<button name="action_cancel" type="object" string="取消" groups="sf_base.group_sf_mrp_user"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='state']" position="replace">
|
||||||
|
<field name="state" decoration-success="state in ('done', 'to_close')"
|
||||||
|
decoration-warning="state == 'progress'" decoration-info="state == 'confirmed'"
|
||||||
|
decoration-danger="state in ('cancel','rework','scrap')" decoration-muted="state == 'draft'"
|
||||||
|
optional="show" widget="badge" class="text-dark"/>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//field[@name='state']" position="after">
|
<xpath expr="//field[@name='state']" position="after">
|
||||||
<field name="tool_state" invisible="1"/>
|
<field name="tool_state" invisible="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
|
<field name="name" decoration-success="is_subcontract" decoration-bf="is_subcontract"/>
|
||||||
</field>
|
</field>
|
||||||
<field name="name" position="before">
|
<field name="name" position="before">
|
||||||
<field name="sequence"/>
|
<field name="sequence" string="序号"/>
|
||||||
<field name='user_permissions' invisible="1"/>
|
<field name='user_permissions' invisible="1"/>
|
||||||
</field>
|
</field>
|
||||||
<field name="name" position="after">
|
<field name="name" position="after">
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
logging.info('下发编程单:%s' % ret)
|
logging.info('下发编程单:%s' % ret)
|
||||||
domain = [('programming_no', '=', ret['programming_no'])]
|
domain = [('programming_no', '=', ret['programming_no'])]
|
||||||
if ret['manufacturing_type'] == 'scrap':
|
if ret['manufacturing_type'] == 'scrap':
|
||||||
domain += [('state', 'not in', ['done', 'scrap'])]
|
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
|
||||||
productions = request.env['mrp.production'].with_user(
|
productions = request.env['mrp.production'].with_user(
|
||||||
request.env.ref("base.user_admin")).search(domain)
|
request.env.ref("base.user_admin")).search(domain)
|
||||||
if productions:
|
if productions:
|
||||||
|
|||||||
@@ -225,45 +225,42 @@ class RePurchaseOrder(models.Model):
|
|||||||
raise UserError('请对【产品】中的【税】进行选择')
|
raise UserError('请对【产品】中的【税】进行选择')
|
||||||
|
|
||||||
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
def get_purchase_order(self, consecutive_process_parameters, production, product_id_to_production_names):
|
||||||
is_exist = True
|
|
||||||
server_product_process = []
|
server_product_process = []
|
||||||
production_process = product_id_to_production_names.get(
|
production_process = product_id_to_production_names.get(
|
||||||
production.product_id.id)
|
production.product_id.id)
|
||||||
for pp in consecutive_process_parameters:
|
for pp in consecutive_process_parameters:
|
||||||
if pp.gain_way == '外协':
|
if pp.gain_way == '外协':
|
||||||
server_product = self.env['product.template'].search(
|
server_template = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', pp.id),
|
[('server_product_process_parameters_id', '=', pp.id),
|
||||||
('detailed_type', '=', 'service')])
|
('detailed_type', '=', 'service')])
|
||||||
purchase_order_line = self.env['purchase.order.line'].search(
|
purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
[('product_id', '=', server_product.id), ('product_qty', '=', len(production_process))])
|
[('product_id', '=', server_template.product_variant_id.id),
|
||||||
|
('product_qty', '=', len(production_process))], limit=1, order='id desc')
|
||||||
if not purchase_order_line:
|
if not purchase_order_line:
|
||||||
is_exist = False
|
|
||||||
server_product_process.append((0, 0, {
|
server_product_process.append((0, 0, {
|
||||||
'product_id': server_product.product_variant_id.id,
|
'product_id': server_template.product_variant_id.id,
|
||||||
'product_qty': len(production_process),
|
'product_qty': len(production_process),
|
||||||
'product_uom': server_product.uom_id.id
|
'product_uom': server_template.uom_id.id
|
||||||
}))
|
}))
|
||||||
else:
|
else:
|
||||||
for item in purchase_order_line:
|
for item in purchase_order_line:
|
||||||
purchase_order = self.env['purchase.order'].search(
|
if production.name in production_process:
|
||||||
[('state', '=', 'draft'), ('origin', 'ilike', production.name),
|
purchase_order = self.env['purchase.order'].search(
|
||||||
('id', '=', item.order_id.id)])
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
||||||
if not purchase_order:
|
('id', '=', item.order_id.id)])
|
||||||
is_exist = False
|
if not purchase_order:
|
||||||
server_product_process.append((0, 0, {
|
server_product_process.append((0, 0, {
|
||||||
'product_id': server_product.product_variant_id.id,
|
'product_id': server_template.product_variant_id.id,
|
||||||
'product_qty': len(production_process),
|
'product_qty': len(production_process),
|
||||||
'product_uom': server_product.uom_id.id
|
'product_uom': server_template.uom_id.id
|
||||||
}))
|
}))
|
||||||
if is_exist is False:
|
if server_product_process:
|
||||||
purchase_order = self.env['purchase.order'].search(
|
self.env['purchase.order'].sudo().create({
|
||||||
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process))])
|
'partner_id': server_template.seller_ids.partner_id.id,
|
||||||
if not purchase_order or len(purchase_order) >= 1:
|
'origin': ','.join(production_process),
|
||||||
self.env['purchase.order'].sudo().create({
|
'state': 'draft',
|
||||||
'partner_id': server_product.seller_ids.partner_id.id,
|
'order_line': server_product_process})
|
||||||
'origin': ','.join(production_process),
|
# self.env.cr.commit()
|
||||||
'state': 'draft',
|
|
||||||
'order_line': server_product_process})
|
|
||||||
|
|
||||||
@api.onchange('order_line')
|
@api.onchange('order_line')
|
||||||
def _onchange_order_line(self):
|
def _onchange_order_line(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user