优化表面工艺
This commit is contained in:
@@ -940,7 +940,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
>>>>>>> 3f27ae0f35c7054b2e6583cc60502d6faef3fc92
|
||||
|
||||
|
||||
# elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
|
||||
# 'rework']:
|
||||
|
||||
@@ -272,73 +272,79 @@ class StockRule(models.Model):
|
||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||
for production_item in productions:
|
||||
if production_item.product_id.id in product_id_to_production_names:
|
||||
# sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids, key=lambda w: w.id)
|
||||
# consecutive_process_parameters = []
|
||||
# m = 0
|
||||
# for i in range(len(sorted_process_parameters) - 1):
|
||||
# if m == 0:
|
||||
# is_pick = False
|
||||
# if sorted_process_parameters[i].supplier_id.id == sorted_process_parameters[i + 1].supplier_id.id and :
|
||||
# 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 + 1])
|
||||
# m += 1
|
||||
# continue
|
||||
# else:
|
||||
# if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_process_parameters,
|
||||
# production_item)
|
||||
# if sorted_process_parameters[i] in consecutive_workorders:
|
||||
# is_pick = True
|
||||
# consecutive_process_parameters = []
|
||||
# m = 0
|
||||
# # 当前面的连续工序生成对应的采购单再生成当前工序的外协采购单
|
||||
# if is_pick is False:
|
||||
# self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||
# production_item)
|
||||
# if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_process_parameters,
|
||||
# production_item)
|
||||
# if sorted_process_parameters[i] in consecutive_process_parameters:
|
||||
# is_pick = True
|
||||
# consecutive_process_parameters = []
|
||||
# m = 0
|
||||
# if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_process_parameters, production_item)
|
||||
# if is_pick is False and m == 0:
|
||||
# if len(sorted_process_parameters) == 1:
|
||||
# self.env['stock.picking'].create_outcontract_picking(sorted_process_parameters, production_item)
|
||||
# else:
|
||||
# self.env['stock.picking'].create_outcontract_picking(sorted_process_parameters[i], production_item)
|
||||
for pp in production_item.product_id.model_process_parameters_ids:
|
||||
if pp.gain_way == '外协':
|
||||
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)])
|
||||
if not purchase_order_line:
|
||||
is_exist = False
|
||||
else:
|
||||
for item in purchase_order_line:
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('state', '=', 'draft'), ('origin', 'ilike', production_item.name),
|
||||
('id', '=', item.order_id)])
|
||||
if not purchase_order:
|
||||
is_exist = False
|
||||
if is_exist is False:
|
||||
production_process = product_id_to_production_names.get(
|
||||
production_item.product_id.id)
|
||||
self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'origin': ','.join(production_process),
|
||||
'state': 'draft',
|
||||
'order_line': [(0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': len(production_process),
|
||||
'product_uom': server_product.uom_id.id
|
||||
})]
|
||||
})
|
||||
sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids,
|
||||
key=lambda w: w.id)
|
||||
consecutive_process_parameters = []
|
||||
m = 0
|
||||
for i in range(len(sorted_process_parameters) - 1):
|
||||
if m == 0:
|
||||
is_purchase = False
|
||||
if sorted_process_parameters[i].supplier_id.id == sorted_process_parameters[
|
||||
i + 1].supplier_id.id and sorted_process_parameters[i].gain_way == '外协':
|
||||
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 + 1])
|
||||
m += 1
|
||||
continue
|
||||
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_workorders:
|
||||
is_purchase = True
|
||||
consecutive_process_parameters = []
|
||||
m = 0
|
||||
# 当前面的连续采购单生成再生成当前工序的外协采购单
|
||||
if is_purchase is False:
|
||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters[i],
|
||||
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,
|
||||
product_id_to_production_names)
|
||||
# for pp in production_item.product_id.model_process_parameters_ids:
|
||||
# if pp.gain_way == '外协':
|
||||
# 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)])
|
||||
# if not purchase_order_line:
|
||||
# is_exist = False
|
||||
# else:
|
||||
# for item in purchase_order_line:
|
||||
# purchase_order = self.env['purchase.order'].search(
|
||||
# [('state', '=', 'draft'), ('origin', 'ilike', production_item.name),
|
||||
# ('id', '=', item.order_id)])
|
||||
# if not purchase_order:
|
||||
# is_exist = False
|
||||
# if is_exist is False:
|
||||
# production_process = product_id_to_production_names.get(
|
||||
# production_item.product_id.id)
|
||||
# self.env['purchase.order'].sudo().create({
|
||||
# 'partner_id': server_product.seller_ids.partner_id.id,
|
||||
# 'origin': ','.join(production_process),
|
||||
# 'state': 'draft',
|
||||
# 'order_line': [(0, 0, {
|
||||
# 'product_id': server_product.product_variant_id.id,
|
||||
# 'product_qty': len(production_process),
|
||||
# 'product_uom': server_product.uom_id.id
|
||||
# })]
|
||||
# })
|
||||
|
||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
@@ -575,18 +581,18 @@ class StockPicking(models.Model):
|
||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
||||
res = super().button_validate()
|
||||
# if res is True:
|
||||
# if self.id == move_out.picking_id.id:
|
||||
# # if move_out.move_line_ids.workorder_id.state == 'progress':
|
||||
# move_in = self.env['stock.move'].search(
|
||||
# [('location_dest_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
# ('location_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
# ('origin', '=', self.origin)])
|
||||
# production = self.env['mrp.production'].search([('name', '=', self.origin)])
|
||||
# if move_in:
|
||||
# move_in.write({'state': 'assigned'})
|
||||
# self.env['stock.move.line'].create(move_in.get_move_line(production, None))
|
||||
# if self.id == move_out.picking_id.id:
|
||||
# # if move_out.move_line_ids.workorder_id.state == 'progress':
|
||||
# move_in = self.env['stock.move'].search(
|
||||
# [('location_dest_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
# ('location_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
# ('origin', '=', self.origin)])
|
||||
# production = self.env['mrp.production'].search([('name', '=', self.origin)])
|
||||
# if move_in:
|
||||
# move_in.write({'state': 'assigned'})
|
||||
# self.env['stock.move.line'].create(move_in.get_move_line(production, None))
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
groups="sf_base.group_sf_mrp_user"/>
|
||||
</xpath>
|
||||
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
||||
<button name="button_scrap" invisible="1"/>
|
||||
<button name="button_scrap" invisible="0"/>
|
||||
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
|
||||
confirm="是否确认更新程序"
|
||||
attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/>
|
||||
|
||||
@@ -211,6 +211,37 @@ class RePurchaseOrder(models.Model):
|
||||
if not line.taxes_id:
|
||||
raise UserError('请对【产品】中的【税】进行选择')
|
||||
|
||||
def get_purchase_order(self, production, product_id_to_production_names):
|
||||
for pp in production.product_id.model_process_parameters_ids:
|
||||
if pp.gain_way == '外协':
|
||||
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)])
|
||||
if not purchase_order_line:
|
||||
is_exist = False
|
||||
else:
|
||||
for item in purchase_order_line:
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('state', '=', 'draft'), ('origin', 'ilike', production.name),
|
||||
('id', '=', item.order_id)])
|
||||
if not purchase_order:
|
||||
is_exist = False
|
||||
if is_exist is False:
|
||||
production_process = product_id_to_production_names.get(
|
||||
production.product_id.id)
|
||||
self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'origin': ','.join(production_process),
|
||||
'state': 'draft',
|
||||
'order_line': [(0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': len(production_process),
|
||||
'product_uom': server_product.uom_id.id
|
||||
})]
|
||||
})
|
||||
|
||||
@api.onchange('order_line')
|
||||
def _onchange_order_line(self):
|
||||
for order in self:
|
||||
@@ -237,7 +268,6 @@ class ResPartnerToSale(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
purchase_user_id = fields.Many2one('res.users', '采购员')
|
||||
translated_display_name = fields.Char('11')
|
||||
|
||||
@api.constrains('name')
|
||||
def _check_name(self):
|
||||
|
||||
Reference in New Issue
Block a user