diff --git a/sf_base/views/tool_menu.xml b/sf_base/views/tool_menu.xml index bad606d6..263d11fa 100644 --- a/sf_base/views/tool_menu.xml +++ b/sf_base/views/tool_menu.xml @@ -21,7 +21,7 @@ 刀具标准库 ir.actions.act_window sf.cutting_tool.standard.library - + tree,form @@ -69,14 +69,22 @@ sequence="20" action="action_sf_cutting_tool_standard_library" /> + + - - - - - - - + + + + + + + + id="menu_sf_maintenance_equipment_image" + name="能力特征库" + parent="menu_sf_cutting_tool" + action="action_maintenance_equipment_image" + sequence="40"/> + id="menu_sf_tool_groups" + name="刀具组" + parent="menu_sf_cutting_tool" + action="sf_tool_groups_view_act" + sequence="50"/> diff --git a/sf_base/views/tool_views.xml b/sf_base/views/tool_views.xml index e52a6222..1e82b8c2 100644 --- a/sf_base/views/tool_views.xml +++ b/sf_base/views/tool_views.xml @@ -609,13 +609,4 @@ tree - - - diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 80a334ce..94a9d646 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -317,13 +317,15 @@ class ProductionLot(models.Model): """ now = datetime.now().strftime("%Y%m%d") last_serial = self.env['stock.lot'].search( - [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'like', now)], + [('company_id', '=', company.id), ('product_id', '=', product.id)], limit=1, order='id DESC') if product.cutting_tool_model_id: + split_codes = product.cutting_tool_model_id.code.split('-') if not last_serial: - return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1) + return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1) else: - return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, int(last_serial.name[-3:]) + 1) + return "%s-T-%s-%s-%03d" % ( + split_codes[0], now, product.specification_id.name, int(last_serial.name[-3:]) + 1) else: raise ValidationError('该刀具物料产品的型号字段为空,请补充完整!!!') @@ -341,7 +343,8 @@ class ProductionLot(models.Model): return self.env['stock.lot'].generate_lot_names1(product.name, last_serial.name, 2)[1] now = datetime.now().strftime("%Y%m%d") if product.cutting_tool_model_id: - return "%s-%s%03d" % (product.cutting_tool_model_id.code[:-12], now, 1) + split_codes = product.cutting_tool_model_id.code.split('-') + return "%s-T-%s-%s-%03d" % (split_codes[0], now, product.specification_id.name, 1) return "%s-%03d" % (product.name, 1) qr_code_image = fields.Binary(string='二维码', compute='_generate_qr_code') @@ -539,6 +542,65 @@ class ReStockMove(models.Model): else: raise UserError(_("没有可打印的标签数据")) + def action_show_details(self): + """ Returns an action that will open a form view (in a popup) allowing to work on all the + move lines of a particular move. This form view is used when "show operations" is not + checked on the picking type. + """ + self.ensure_one() + + # If "show suggestions" is not checked on the picking type, we have to filter out the + # reserved move lines. We do this by displaying `move_line_nosuggest_ids`. We use + # different views to display one field or another so that the webclient doesn't have to + # fetch both. + if self.picking_type_id.show_reserved: + view = self.env.ref('stock.view_stock_move_operations') + else: + view = self.env.ref('stock.view_stock_move_nosuggest_operations') + + if self.product_id.tracking == "serial" and self.state == "assigned": + print(self.origin) + if self.product_id.categ_id.name == '刀具': + self.next_serial = self._get_tool_next_serial(self.company_id, self.product_id, self.origin) + else: + self.next_serial = self.env['stock.lot']._get_next_serial(self.company_id, self.product_id) + + return { + 'name': _('Detailed Operations'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'stock.move', + 'views': [(view.id, 'form')], + 'view_id': view.id, + 'target': 'new', + 'res_id': self.id, + 'context': dict( + self.env.context, + show_owner=self.picking_type_id.code != 'incoming', + show_lots_m2o=self.has_tracking != 'none' and ( + self.picking_type_id.use_existing_lots or self.state == 'done' or self.origin_returned_move_id.id), + # able to create lots, whatever the value of ` use_create_lots`. + show_lots_text=self.has_tracking != 'none' and self.picking_type_id.use_create_lots and not self.picking_type_id.use_existing_lots and self.state != 'done' and not self.origin_returned_move_id.id, + show_source_location=self.picking_type_id.code != 'incoming', + show_destination_location=self.picking_type_id.code != 'outgoing', + show_package=not self.location_id.usage == 'supplier', + show_reserved_quantity=self.state != 'done' and not self.picking_id.immediate_transfer and self.picking_type_id.code != 'incoming' + ), + } + + def _get_tool_next_serial(self, company, product, origin): + """Return the next serial number to be attributed to the product.""" + if product.tracking == "serial": + last_serial = self.env['stock.lot'].search( + [('company_id', '=', company.id), ('product_id', '=', product.id), ('name', 'ilike', origin)], + limit=1, order='id DESC') + split_codes = product.cutting_tool_model_id.code.split('-') + if last_serial: + return "%s-T-%s-%s-%03d" % ( + split_codes[0], origin, product.specification_id.name, int(last_serial.name[-3:]) + 1) + else: + return "%s-T-%s-%s-%03d" % (split_codes[0], origin, product.specification_id.name, 1) + class ReStockQuant(models.Model): _inherit = 'stock.quant' diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index e2313ba3..05523194 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -206,6 +206,16 @@ class RePurchaseOrder(models.Model): order.message_subscribe([order.partner_id.id]) return True + @api.onchange('order_line') + def _onchange_order_line(self): + for order in self: + if order.order_line: + line = order.order_line + product = line.product_id + product_id = product.ids + if len(product_id) != len(line): + raise ValidationError('【%s】已存在,请勿重复添加' % product[-1].name) + class ResPartnerToSale(models.Model): _inherit = 'res.partner'