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