1、处理销售单的依赖导致的更新报错问题;2、优化客供料单据获取销售单字段信息和成品信息方法;
This commit is contained in:
@@ -548,35 +548,42 @@ class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数")
|
||||
person_of_delivery = fields.Char('收货人', compute='_compute_origin', store=True)
|
||||
telephone_of_delivery = fields.Char('电话号码', compute='_compute_origin', store=True)
|
||||
address_of_delivery = fields.Char('联系地址', compute='_compute_origin')
|
||||
person_of_delivery = fields.Char('收货人', compute='_compute_move_ids', store=True)
|
||||
telephone_of_delivery = fields.Char('电话号码', compute='_compute_move_ids', store=True)
|
||||
address_of_delivery = fields.Char('联系地址', compute='_compute_move_ids', store=True)
|
||||
|
||||
retrospect_ref = fields.Char('追溯参考', compute='_compute_origin', store=True)
|
||||
retrospect_ref = fields.Char('追溯参考', compute='_compute_move_ids', store=True)
|
||||
|
||||
@api.depends('origin')
|
||||
def _compute_origin(self):
|
||||
"""
|
||||
计算带料入库单对应销售单
|
||||
"""
|
||||
@api.depends('move_ids')
|
||||
def _compute_move_ids(self):
|
||||
for item in self:
|
||||
if item.picking_type_id.sequence_code == 'DL' and item.origin:
|
||||
if 'WH/IN/' in item.origin:
|
||||
picking_id = self.env['stock.picking'].search([('name', '=', item.origin)])
|
||||
if picking_id and picking_id.origin:
|
||||
purchase_id = self.env['purchase.order'].sudo().search([('name', '=', picking_id.origin)])
|
||||
if purchase_id and purchase_id.origin:
|
||||
sale_id = self.env['sale.order'].sudo().search([('name', '=', purchase_id.origin)])
|
||||
item.person_of_delivery = sale_id.person_of_delivery
|
||||
item.telephone_of_delivery = sale_id.telephone_of_delivery
|
||||
item.address_of_delivery = sale_id.address_of_delivery
|
||||
|
||||
bom = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', '=', self.move_ids.product_id.id)])
|
||||
if bom:
|
||||
if item.move_ids:
|
||||
if item.picking_type_id.sequence_code == 'DL':
|
||||
item.retrospect_ref = bom.product_tmpl_id.default_code
|
||||
sale_name = item.move_ids[0].product_id.name.split('-')[1]
|
||||
if 'S' in sale_name:
|
||||
sale_id = self.env['sale.order'].sudo().search([('name', '=', sale_name)])
|
||||
item.person_of_delivery = sale_id.person_of_delivery
|
||||
item.telephone_of_delivery = sale_id.telephone_of_delivery
|
||||
item.address_of_delivery = sale_id.address_of_delivery
|
||||
else:
|
||||
raise ValidationError('坯料名称格式错误,正确格式为[R-S???-?]!!!')
|
||||
move_ids = []
|
||||
for move_id in item.move_ids:
|
||||
move_ids.append(move_id.product_id.id)
|
||||
boms = self.env['mrp.bom'].sudo().search([('bom_line_ids.product_id', 'in', move_ids)])
|
||||
default_codes = ''
|
||||
if boms:
|
||||
for bom in boms:
|
||||
code = bom.product_tmpl_id.default_code.split('-')[-1]
|
||||
default_code = bom.product_tmpl_id.default_code.split(f'-{code}')[0]
|
||||
if default_code not in default_codes:
|
||||
if default_codes == '':
|
||||
default_codes = default_code
|
||||
else:
|
||||
default_codes = default_codes + ',' + default_code
|
||||
item.retrospect_ref = default_codes
|
||||
elif item.picking_type_id.sequence_code in ['INT', 'PC']:
|
||||
item.retrospect_ref = bom.product_tmpl_id.name
|
||||
pass
|
||||
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
|
||||
Reference in New Issue
Block a user