新增根据模型类型计算出产品的胚料尺寸

This commit is contained in:
jinling.yang
2022-10-31 17:34:44 +08:00
parent 002653957e
commit 7067b29735
6 changed files with 73 additions and 53 deletions

View File

@@ -1,4 +1,4 @@
from odoo import models, fields
from odoo import models, fields,api
from odoo.exceptions import ValidationError
@@ -45,6 +45,22 @@ class ResProductTemplate(models.Model):
copy_product_id.sudo().write(vals)
return copy_product_id
# 在产品上增加模型类型和加工的面例如A、B)
# 并根据模型类型计算出产品的胚料尺寸;
@api.onchange('model_type_id')
def count_embryo_size(self):
bom = self.env['mrp.bom.line'].search(
[('product_tmpl_id', '=', self.id)])
for item in self:
print(bom.product_tmpl_id)
print(bom.model_long)
item.model_long = bom.model_long + 1
print(item.model_long)
item.embryo_width = bom.embryo_width + 1
item.embryo_height = bom.embryo_height + 1
class ResProductCategory(models.Model):
_inherit = "product.category"
@@ -94,3 +110,7 @@ class ResMrpBom(models.Model):