Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造功能优化
This commit is contained in:
@@ -1531,10 +1531,9 @@ class MrpProduction(models.Model):
|
|||||||
"""
|
"""
|
||||||
重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建
|
重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建
|
||||||
"""
|
"""
|
||||||
|
product_group_id = {}
|
||||||
group_id = False
|
group_id = False
|
||||||
first_origin = next((obj['origin'] for obj in vals_list if 'origin' in obj), None)
|
is_first = False
|
||||||
if first_origin:
|
|
||||||
group_id = self.env["procurement.group"].create({'name':first_origin}).id
|
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
if not vals.get('name', False) or vals['name'] == _('New'):
|
if not vals.get('name', False) or vals['name'] == _('New'):
|
||||||
picking_type_id = vals.get('picking_type_id')
|
picking_type_id = vals.get('picking_type_id')
|
||||||
@@ -1542,7 +1541,22 @@ class MrpProduction(models.Model):
|
|||||||
picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.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['picking_type_id'] = picking_type_id
|
||||||
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id()
|
||||||
if not vals.get('procurement_group_id') and group_id:
|
if not is_first:
|
||||||
|
is_first = True
|
||||||
|
group_id = self.env["procurement.group"].create({'name': vals.get('name')}).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:
|
||||||
|
if product_id.categ_id.name =='成品':
|
||||||
|
vals['procurement_group_id'] = group_id
|
||||||
|
continue
|
||||||
|
if product_id.id not in product_group_id.keys():
|
||||||
|
procurement_group_vals = self._prepare_procurement_group_vals(vals)
|
||||||
|
group_id = self.env["procurement.group"].create(procurement_group_vals).id
|
||||||
|
vals['procurement_group_id'] = group_id
|
||||||
|
product_group_id[product_id.id] = group_id
|
||||||
|
else:
|
||||||
|
vals['procurement_group_id'] = product_group_id[product_id.id]
|
||||||
vals['procurement_group_id'] = group_id
|
vals['procurement_group_id'] = group_id
|
||||||
return super(MrpProduction, self).create(vals_list)
|
return super(MrpProduction, self).create(vals_list)
|
||||||
|
|
||||||
|
|||||||
@@ -93,15 +93,16 @@ class PurchaseOrder(models.Model):
|
|||||||
|
|
||||||
class PurchaseOrderLine(models.Model):
|
class PurchaseOrderLine(models.Model):
|
||||||
_inherit = 'purchase.order.line'
|
_inherit = 'purchase.order.line'
|
||||||
|
|
||||||
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
part_number = fields.Char('零件图号', related='product_id.part_number', readonly=True)
|
||||||
related_product = fields.Many2one('product.product', compute='_compute_related_product', string='关联产品',
|
related_product = fields.Many2one('product.product', string='关联产品',
|
||||||
help='经此产品工艺加工成的成品')
|
help='经此产品工艺加工成的成品')
|
||||||
|
|
||||||
@api.depends('order_id.origin')
|
# @api.depends('order_id.origin')
|
||||||
def _compute_related_product(self):
|
# def _compute_related_product(self):
|
||||||
for record in self:
|
# for record in self:
|
||||||
if record.product_id.detailed_type:
|
# if record.product_id.detailed_type:
|
||||||
production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
# production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
||||||
record.related_product = production_id.product_id if production_id else False
|
# record.related_product = production_id.product_id if production_id else False
|
||||||
else:
|
# else:
|
||||||
record.related_product = False
|
# record.related_product = False
|
||||||
|
|||||||
@@ -355,7 +355,8 @@ class RePurchaseOrder(models.Model):
|
|||||||
server_product_process.append((0, 0, {
|
server_product_process.append((0, 0, {
|
||||||
'product_id': server_template.product_variant_id.id,
|
'product_id': server_template.product_variant_id.id,
|
||||||
'product_qty': 1,
|
'product_qty': 1,
|
||||||
'product_uom': server_template.uom_id.id
|
'product_uom': server_template.uom_id.id,
|
||||||
|
'related_product': production.product_id.id,
|
||||||
}))
|
}))
|
||||||
# 获取服务商品最后一个供应商的采购员
|
# 获取服务商品最后一个供应商的采购员
|
||||||
purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id
|
purchase_user_id = server_template.seller_ids[-1].partner_id.purchase_user_id
|
||||||
|
|||||||
Reference in New Issue
Block a user