diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index be0c09ae..1489cddd 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,7 +7,6 @@ from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path - from OCC.Extend.DataExchange import read_step_file from OCC.Extend.DataExchange import write_stl_file @@ -107,7 +106,10 @@ class ResProductMo(models.Model): @api.onchange('cutting_tool_model_id') def _onchange_cutting_tool_model_id(self): - self.specification_id = False + for item in self: + if item: + item.specification_id = False + item.cutting_tool_chuck_id = item.cutting_tool_model_id.chuck_id @api.onchange('cutting_tool_material_id') def _onchange_cutting_tool_material_id(self): @@ -310,7 +312,6 @@ class ResProductMo(models.Model): self.cutting_tool_is_safety_lock = self.specification_id.is_safe_lock self.cutting_tool_fit_nut_model = self.specification_id.nut self.cutting_tool_wrench = self.specification_id.spanner - self.cutting_tool_chuck_id = self.specification_id.chuck_id.id self.cutting_tool_jump_accuracy = self.specification_id.diameter_slip_accuracy self.cutting_tool_taper_shank_model = self.specification_id.taper_shank_model self.cutting_tool_cooling_type = self.specification_id.cooling_model diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index b85f7ac4..d777d48b 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -222,6 +222,22 @@ class ProductionLot(models.Model): _name = 'stock.lot' _inherit = ['stock.lot', 'printing.utils'] + rfid = fields.Char('Rfid', readonly=True) + product_material_name = fields.Char('刀具产品物料名称', related='product_id.cutting_tool_material_id.name') + product_specification = fields.Char('规格', compute='_compute_product_specification', store=True) + + @api.depends('product_id') + def _compute_product_specification(self): + for stock in self: + if stock: + if stock.product_id: + if stock.product_id.categ_id.name in '刀具': + stock.product_specification = stock.product_id.specification_id.name + elif stock.product_id.categ_id.name in '夹具': + stock.product_specification = stock.product_id.specification_fixture_id.name + else: + stock.product_specification = stock.product_id.default_code + @api.model def generate_lot_names1(self, display_name, first_lot, count): """Generate `lot_names` from a string.""" diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 0ae0d95f..6ba78573 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -422,7 +422,8 @@
规格: - + +
[] diff --git a/sf_manufacturing/views/stock_lot_views.xml b/sf_manufacturing/views/stock_lot_views.xml index bd04005c..f7ef9c9b 100644 --- a/sf_manufacturing/views/stock_lot_views.xml +++ b/sf_manufacturing/views/stock_lot_views.xml @@ -13,6 +13,12 @@