diff --git a/sf_base/models/base.py b/sf_base/models/base.py index 3d83cc96..2c4bf22a 100644 --- a/sf_base/models/base.py +++ b/sf_base/models/base.py @@ -402,3 +402,11 @@ class MachiningAccuracy(models.Model): name = fields.Char('一般公差', index=True) standard_tolerance = fields.Char(string="标准公差") sync_id = fields.Char('同步ID') + + +class ReSaleOrder(models.Model): + _inherit = 'sale.order' + + person_of_delivery = fields.Char('收货人') + telephone_of_delivery = fields.Char('电话号码') + address_of_delivery = fields.Char('联系地址') diff --git a/sf_maintenance/views/maintenance_request_views.xml b/sf_maintenance/views/maintenance_request_views.xml index 9353e80e..b76326b8 100644 --- a/sf_maintenance/views/maintenance_request_views.xml +++ b/sf_maintenance/views/maintenance_request_views.xml @@ -139,7 +139,7 @@ 维保计划 maintenance.request tree,kanban,form,pivot,graph,calendar - + {'default_user_id': uid}

diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index fb678fd3..55667d41 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -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): diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index bc34c134..01d5953b 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -32,9 +32,9 @@ class ReSaleOrder(models.Model): tracking=3, default='draft') deadline_of_delivery = fields.Date('订单交期', tracking=True) - person_of_delivery = fields.Char('收货人') - telephone_of_delivery = fields.Char('电话号码') - address_of_delivery = fields.Char('联系地址') + # person_of_delivery = fields.Char('收货人') + # telephone_of_delivery = fields.Char('电话号码') + # address_of_delivery = fields.Char('联系地址') payments_way = fields.Selection([('现结', '现结'), ('月结', '月结')], '结算方式', default='现结', tracking=True) pay_way = fields.Selection([('转账', '转账'), ('微信', '微信'), ('支付宝', '支付宝')], '支付方式') check_status = fields.Selection([('pending', '待审核'), ('approved', '已审核'), ('fail', '不通过')], '审核状态') diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index a83faa6a..092e0113 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -450,7 +450,7 @@ - +