修改订单客供料显示,修改内部调拨、生产发料合并单据
This commit is contained in:
@@ -125,30 +125,36 @@ class StockRule(models.Model):
|
||||
|
||||
product = self.env['product.product'].search(
|
||||
[("id", '=', item[0].product_id.id)])
|
||||
product_tmpl = self.env['product.template'].search(
|
||||
["&", ("id", '=', product.product_tmpl_id.id), ('single_manufacturing', "!=", False)])
|
||||
if product_tmpl:
|
||||
if num > 1:
|
||||
for no in range(1, num + 1):
|
||||
Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
||||
'product_uom', 'location_id', 'name', 'origin',
|
||||
'company_id',
|
||||
'values'])
|
||||
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom,
|
||||
location_id=item[0].location_id,
|
||||
name=item[0].name,
|
||||
origin=item[0].origin,
|
||||
company_id=item[0].company_id,
|
||||
values=item[0].values,
|
||||
)
|
||||
item1 = list(item)
|
||||
item1[0] = s
|
||||
# 如果产品是坯料,则根据作业类型来设置采购组
|
||||
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:
|
||||
if num > 1:
|
||||
for no in range(1, num + 1):
|
||||
Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
||||
'product_uom', 'location_id', 'name', 'origin',
|
||||
'company_id',
|
||||
'values'])
|
||||
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom,
|
||||
location_id=item[0].location_id,
|
||||
name=item[0].name,
|
||||
origin=item[0].origin,
|
||||
company_id=item[0].company_id,
|
||||
values=item[0].values,
|
||||
)
|
||||
item1 = list(item)
|
||||
item1[0] = s
|
||||
|
||||
list2.append(tuple(item1))
|
||||
list2.append(tuple(item1))
|
||||
else:
|
||||
list2.append(item)
|
||||
else:
|
||||
list2.append(item)
|
||||
else:
|
||||
list2.append(item)
|
||||
|
||||
for procurement, rule in list2:
|
||||
procure_method = rule.procure_method
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user