修改订单客供料显示,修改内部调拨、生产发料合并单据
This commit is contained in:
@@ -1383,6 +1383,53 @@ class MrpProduction(models.Model):
|
||||
for production in self:
|
||||
production.production_type = '自动化产线加工' if not production.product_id.is_manual_processing else '人工线下加工'
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
"""
|
||||
重载创建制造订单的方法,单件制造订单只创建一个采购组,用于后续单据的创建
|
||||
"""
|
||||
group_id = None
|
||||
for vals in vals_list:
|
||||
if not vals.get('name', False) or vals['name'] == _('New'):
|
||||
picking_type_id = vals.get('picking_type_id')
|
||||
if not picking_type_id:
|
||||
picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.id))
|
||||
vals['picking_type_id'] = picking_type_id
|
||||
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
||||
if not vals.get('procurement_group_id'):
|
||||
product_id = self.env['product.product'].browse(vals['product_id'])
|
||||
if product_id.product_tmpl_id.single_manufacturing:
|
||||
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
||||
group_id = self.env["procurement.group"].create(procurement_group_vals).id if not group_id else group_id
|
||||
vals['procurement_group_id'] = group_id
|
||||
return super(MrpProduction, self).create(vals_list)
|
||||
|
||||
@api.depends('procurement_group_id.stock_move_ids.created_purchase_line_id.order_id', 'procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id')
|
||||
def _compute_purchase_order_count(self):
|
||||
for production in self:
|
||||
# 找到来源的第一张制造订单的采购组
|
||||
if production.product_id.product_tmpl_id.single_manufacturing == True:
|
||||
first_production = self.env['mrp.production'].search([('origin', '=', production.origin)], limit=1, order='id asc')
|
||||
production.purchase_order_count = len(first_production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
||||
first_production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
||||
else:
|
||||
production.purchase_order_count = len(production.procurement_group_id.stock_move_ids.created_purchase_line_id.order_id |
|
||||
production.procurement_group_id.stock_move_ids.move_orig_ids.purchase_line_id.order_id)
|
||||
|
||||
@api.depends('procurement_group_id', 'procurement_group_id.stock_move_ids.group_id')
|
||||
def _compute_picking_ids(self):
|
||||
for order in self:
|
||||
if order.product_id.product_tmpl_id.single_manufacturing == True:
|
||||
first_order = self.env['mrp.production'].search([('origin', '=', order.origin)], limit=1, order='id asc')
|
||||
order.picking_ids = self.env['stock.picking'].search([
|
||||
('group_id', '=', first_order.procurement_group_id.id), ('group_id', '!=', False),
|
||||
])
|
||||
order.delivery_count = len(first_order.picking_ids)
|
||||
else:
|
||||
order.picking_ids = self.env['stock.picking'].search([
|
||||
('group_id', '=', order.procurement_group_id.id), ('group_id', '!=', False),
|
||||
])
|
||||
order.delivery_count = len(order.picking_ids)
|
||||
|
||||
class sf_detection_result(models.Model):
|
||||
_name = 'sf.detection.result'
|
||||
|
||||
@@ -125,6 +125,12 @@ class StockRule(models.Model):
|
||||
|
||||
product = self.env['product.product'].search(
|
||||
[("id", '=', item[0].product_id.id)])
|
||||
# 如果产品是坯料,则根据作业类型来设置采购组
|
||||
if product.categ_id.name == '坯料':
|
||||
if item[1]['picking_type_id'].name in ['生产发料', '内部调拨']:
|
||||
item[0][7]['group_id'] = procurements[0][0][7]['group_id']
|
||||
list2.append(item)
|
||||
else:
|
||||
product_tmpl = self.env['product.template'].search(
|
||||
["&", ("id", '=', product.product_tmpl_id.id), ('single_manufacturing', "!=", False)])
|
||||
if product_tmpl:
|
||||
@@ -208,6 +214,12 @@ class StockRule(models.Model):
|
||||
'''创建制造订单'''
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||
productions_values)
|
||||
# 将这一批制造订单的采购组设置为不同的采购组
|
||||
for index, production in enumerate(productions):
|
||||
if index > 0:
|
||||
productions_values[index].update({'name': production.name})
|
||||
procurement_group_vals = production._prepare_procurement_group_vals(productions_values[index])
|
||||
production.procurement_group_id = self.env["procurement.group"].create(procurement_group_vals).id
|
||||
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
@@ -941,10 +953,28 @@ class ReStockMove(models.Model):
|
||||
qty_by_location[loc.id] += 1
|
||||
return move_lines_commands
|
||||
|
||||
# def _prepare_procurement_origin(self):
|
||||
# """修改采购来源"""
|
||||
# self.ensure_one()
|
||||
# return self.group_id and self.group_id.name or (self.origin or self.picking_id.name or "/")
|
||||
def _merge_moves_fields(self):
|
||||
"""
|
||||
合并制造订单的完成move单据
|
||||
"""
|
||||
res = super(ReStockMove, self)._merge_moves_fields()
|
||||
res = self._single_manufactuing_mo_generate_origin(res)
|
||||
return res
|
||||
|
||||
def _get_new_picking_values(self):
|
||||
res = super(ReStockMove, self)._get_new_picking_values()
|
||||
res = self._single_manufactuing_mo_generate_origin(res)
|
||||
return res
|
||||
|
||||
def _single_manufactuing_mo_generate_origin(self, res):
|
||||
"""
|
||||
单件制造订单的完成move单据修改来源为制造订单
|
||||
"""
|
||||
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||
productions = self.env['mrp.production'].search([('origin', '=', production.origin)])
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
return res
|
||||
|
||||
|
||||
class ReStockQuant(models.Model):
|
||||
|
||||
@@ -178,3 +178,4 @@ access_sf_production_technology_re_adjust_wizard_group_production_engineer,sf_pr
|
||||
access_sf_manual_product_model_type_routing_sort_group_sf_mrp_user,sf_manual_product_model_type_routing_sort,model_sf_manual_product_model_type_routing_sort,sf_base.group_sf_mrp_user,1,0,0,0
|
||||
access_sf_manual_product_model_type_routing_sort_manager,sf_manual_product_model_type_routing_sort,model_sf_manual_product_model_type_routing_sort,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||
access_sf_manual_product_model_type_routing_sort_group_plan_dispatch,sf_manual_product_model_type_routing_sort_group_plan_dispatch,model_sf_manual_product_model_type_routing_sort,sf_base.group_plan_dispatch,1,0,0,0
|
||||
access_sf_detection_result_manager,sf_detection_result_manager,model_sf_detection_result,,1,1,1,1
|
||||
|
||||
|
@@ -133,7 +133,7 @@ class ReSaleOrder(models.Model):
|
||||
'product_uom_qty': item['number'],
|
||||
'model_glb_file': base64.b64decode(item['model_file']),
|
||||
'remark': item.get('remark'),
|
||||
'embryo_redundancy_id': item.get('embryo_redundancy_id'),
|
||||
'is_incoming_material': True if item.get('embryo_redundancy_id') else False,
|
||||
'manual_quotation': item.get('manual_quotation')
|
||||
}
|
||||
return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)
|
||||
@@ -175,10 +175,15 @@ class ResaleOrderLine(models.Model):
|
||||
check_status = fields.Selection(related='order_id.check_status')
|
||||
remark = fields.Char('备注')
|
||||
|
||||
# is_incoming_material = fields.Boolean('客供料', default=False)
|
||||
is_incoming_material = fields.Boolean('客供料', compute='_compute_is_incoming_material', store=True)
|
||||
embryo_redundancy_id = fields.Many2one('sf.embryo.redundancy', '坯料冗余')
|
||||
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||
|
||||
@api.depends('embryo_redundancy_id')
|
||||
def _compute_is_incoming_material(self):
|
||||
for line in self:
|
||||
line.is_incoming_material = True if line.embryo_redundancy_id else False
|
||||
|
||||
@api.depends('product_template_id')
|
||||
def _compute_model_glb_file(self):
|
||||
for line in self:
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<field name="name" widget="section_and_note_text" optional="show"
|
||||
string="参数说明(长/宽/高/体积/精度/材质)"/>
|
||||
<field name="manual_quotation" readonly="1"/>
|
||||
<field name="embryo_redundancy_id" readonly="1"/>
|
||||
<field name="is_incoming_material" readonly="1"/>
|
||||
</xpath>
|
||||
<field name="user_id" position="attributes">
|
||||
<attribute name="attrs">{'readonly': [('state', 'in', ['cancel','sale'])]}</attribute>
|
||||
@@ -167,7 +167,7 @@
|
||||
<!--新增带料字段-->
|
||||
<xpath expr="//field[@name='order_line']/form//group//group//field[@name='analytic_distribution']" position="after">
|
||||
<field name="manual_quotation" />
|
||||
<field name="embryo_redundancy_id"/>
|
||||
<field name="is_incoming_material"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user