Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/commercially_launched
This commit is contained in:
@@ -61,11 +61,29 @@ class MrsMaterialModel(models.Model):
|
|||||||
supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商')
|
supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商')
|
||||||
active = fields.Boolean('有效', default=True)
|
active = fields.Boolean('有效', default=True)
|
||||||
|
|
||||||
|
def write(self, vals):
|
||||||
|
res = super(MrsMaterialModel, self).write(vals)
|
||||||
|
if not self.gain_way:
|
||||||
|
self.gain_way = '采购'
|
||||||
|
if not self.supplier_ids:
|
||||||
|
supplier_id = self.env['res.partner'].search([('name', 'like', '%傲派%')], limit=1)
|
||||||
|
if not supplier_id:
|
||||||
|
supplier_id = self.env['res.partner'].create({
|
||||||
|
'name': '湖南傲派自动化设备有限公司',
|
||||||
|
'supplier_rank':1,
|
||||||
|
})
|
||||||
|
self.supplier_ids = [(0, 0, {'materials_model_id': self.id, 'partner_id': supplier_id.id or False})]
|
||||||
|
return res
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
res = super(MrsMaterialModel, self).create(vals)
|
res = super(MrsMaterialModel, self).create(vals)
|
||||||
if not vals.get('supplier_ids'):
|
if not vals.get('supplier_ids'):
|
||||||
supplier_id = self.env['res.partner'].search([('name', '=', '湖南傲派自动化设备有限公司')], limit=1)
|
supplier_id = self.env['res.partner'].search([('name', 'like', '%傲派%')], limit=1)
|
||||||
|
if not supplier_id:
|
||||||
|
supplier_id = self.env['res.partner'].create({
|
||||||
|
'name': '湖南傲派自动化设备有限公司',
|
||||||
|
'supplier_rank': 1,
|
||||||
|
})
|
||||||
res.supplier_ids = [(0, 0, {'materials_model_id': res.id, 'partner_id': supplier_id.id or False})]
|
res.supplier_ids = [(0, 0, {'materials_model_id': res.id, 'partner_id': supplier_id.id or False})]
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -109,15 +109,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('零件图号', store=True, compute='_compute_related_product')
|
part_number = fields.Char('零件图号', store=True, compute='_compute_part_number')
|
||||||
part_name = fields.Char('零件名称', store=True,
|
part_name = fields.Char('零件名称', store=True, compute='_compute_part_name')
|
||||||
compute='_compute_related_product')
|
|
||||||
related_product = fields.Many2one('product.product', string='关联产品',
|
related_product = fields.Many2one('product.product', string='关联产品',
|
||||||
help='经此产品工艺加工成的成品')
|
help='经此产品工艺加工成的成品')
|
||||||
|
manual_part_name = fields.Char()
|
||||||
|
|
||||||
@api.depends('product_id')
|
@api.depends('product_id')
|
||||||
def _compute_related_product(self):
|
def _compute_part_number(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.part_number or record.part_name:
|
if record.part_number and record.part_name:
|
||||||
continue
|
continue
|
||||||
if record.product_id.categ_id.name == '坯料':
|
if record.product_id.categ_id.name == '坯料':
|
||||||
product_name = ''
|
product_name = ''
|
||||||
@@ -135,13 +136,11 @@ class PurchaseOrderLine(models.Model):
|
|||||||
filtered_order_line = sale_order.order_line.filtered(
|
filtered_order_line = sale_order.order_line.filtered(
|
||||||
lambda order_line: re.search(f'{product_name}$', order_line.product_id.name)
|
lambda order_line: re.search(f'{product_name}$', order_line.product_id.name)
|
||||||
)
|
)
|
||||||
record.part_number = filtered_order_line.product_id.part_number if filtered_order_line else None
|
record.part_number = filtered_order_line.product_id.part_number
|
||||||
record.part_name = filtered_order_line.product_id.part_name if filtered_order_line else None
|
record.part_name = filtered_order_line.product_id.part_name
|
||||||
else:
|
else:
|
||||||
record.part_number = record.product_id.part_number
|
record.part_number = record.product_id.part_number
|
||||||
record.part_name = record.product_id.part_name
|
record.part_name = record.product_id.part_name
|
||||||
# if record.product_id.detailed_type:
|
if record.manual_part_name:
|
||||||
# production_id = self.env['mrp.production'].search([('name', '=', record.order_id.origin)])
|
# 如果手动设置了 part_name,使用手动设置的值
|
||||||
# record.related_product = production_id.product_id if production_id else False
|
record.part_name = record.manual_part_name
|
||||||
# else:
|
|
||||||
# record.related_product = False
|
|
||||||
@@ -21,7 +21,9 @@ class StockPicking(models.Model):
|
|||||||
“警告:存在不合格产品XXXX n 件、YYYYY m件,继续调拨请点“确认”,否则请取消?”
|
“警告:存在不合格产品XXXX n 件、YYYYY m件,继续调拨请点“确认”,否则请取消?”
|
||||||
"""
|
"""
|
||||||
context = self.env.context
|
context = self.env.context
|
||||||
if not context.get('again_validate') and self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail'):
|
if (not (isinstance(res, dict) and res.get('type') == 'ir.actions.act_window')
|
||||||
|
and not context.get('again_validate')
|
||||||
|
and self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail')):
|
||||||
# 回滚事务,为二次确认/取消做准备
|
# 回滚事务,为二次确认/取消做准备
|
||||||
self.env.cr.rollback()
|
self.env.cr.rollback()
|
||||||
quality_check_ids = self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail')
|
quality_check_ids = self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail')
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ class RePurchaseOrder(models.Model):
|
|||||||
'product_uom': server_template.uom_id.id,
|
'product_uom': server_template.uom_id.id,
|
||||||
'related_product': production.product_id.id,
|
'related_product': production.product_id.id,
|
||||||
'part_number': pp.part_number,
|
'part_number': pp.part_number,
|
||||||
'part_name': pp.part_name,
|
'manual_part_name': pp.part_name,
|
||||||
}))
|
}))
|
||||||
# 获取服务商品最后一个供应商的采购员
|
# 获取服务商品最后一个供应商的采购员
|
||||||
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
|
||||||
@@ -399,6 +399,7 @@ class RePurchaseOrder(models.Model):
|
|||||||
'order_line': server_product_process,
|
'order_line': server_product_process,
|
||||||
'user_id': purchase_user_id.id
|
'user_id': purchase_user_id.id
|
||||||
})
|
})
|
||||||
|
purchase_order.order_line._compute_part_number()
|
||||||
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
pp.purchase_id = [(6, 0, [purchase_order.id])]
|
||||||
# self.env.cr.commit()
|
# self.env.cr.commit()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user