优化odoo16工单视图展示问题
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
import logging
|
||||
|
||||
|
||||
class ResProductTemplate(models.Model):
|
||||
@@ -9,7 +10,7 @@ class ResProductTemplate(models.Model):
|
||||
model_long = fields.Float('模型长[mm]', digits=(16, 3))
|
||||
model_width = fields.Float('模型宽[mm]', digits=(16, 3))
|
||||
model_height = fields.Float('模型高[mm]', digits=(16, 3))
|
||||
model_volume = fields.Float('模型体积[mm]', compute='_compute_model_volume', store=True)
|
||||
model_volume = fields.Float('模型体积[m³]')
|
||||
model_machining_precision = fields.Selection([
|
||||
('±0.10mm', '±0.10mm'),
|
||||
('±0.05mm', '±0.05mm'),
|
||||
@@ -22,35 +23,38 @@ class ResProductTemplate(models.Model):
|
||||
model_process_parameters_id = fields.Many2one('sf.processing.technology', string='工艺参数')
|
||||
model_price = fields.Float('模型单价', digits=(16, 3))
|
||||
model_remark = fields.Char('模型备注说明')
|
||||
long = fields.Float('长[mm]', digits=(16, 3))
|
||||
length = fields.Float('长[mm]', digits=(16, 3))
|
||||
width = fields.Float('宽[mm]', digits=(16, 3))
|
||||
height = fields.Float('高[mm]', digits=(16, 3))
|
||||
materials_id = fields.Many2one('sf.production.materials', string='材料')
|
||||
materials_type_id = fields.Many2one('sf.materials.model', string='材料型号')
|
||||
volume = fields.Float(compute='_compute_volume', store=True)
|
||||
# volume = fields.Float(compute='_compute_volume', store=True)
|
||||
single_manufacturing = fields.Boolean(string="单个制造")
|
||||
|
||||
@api.depends('long', 'width', 'height')
|
||||
def _compute_volume(self):
|
||||
self.volume = self.long * self.width * self.height
|
||||
# @api.depends('long', 'width', 'height')
|
||||
# def _compute_volume(self):
|
||||
# self.volume = self.long * self.width * self.height
|
||||
|
||||
@api.depends('model_long', 'model_width', 'model_height')
|
||||
def _compute_model_volume(self):
|
||||
self.model_volume = self.model_long * self.model_width * self.model_height
|
||||
# @api.depends('model_long', 'model_width', 'model_height')
|
||||
# def _compute_model_volume(self):
|
||||
# self.model_volume = self.model_long * self.model_width * self.model_height
|
||||
|
||||
# 业务平台分配工厂后在智能工厂先创建销售订单再创建该产品
|
||||
def product_create(self, product_id, item, order_id, order_number, i):
|
||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
copy_product_id.product_tmpl_id.active = True
|
||||
logging.info('product_create:%s' % item)
|
||||
vals = {
|
||||
'name': '%s-%s' % (order_id.name, i),
|
||||
'model_long': item['model_long'],
|
||||
'model_width': item['model_width'],
|
||||
'model_height': item['model_height'],
|
||||
'model_volume': item['model_volume'],
|
||||
'length': item['long'],
|
||||
'width': item['width'],
|
||||
'height': item['height'],
|
||||
'volume': item['long'] * item['width'] * item['height'],
|
||||
'model_price': item['price'],
|
||||
'model_total_amount': item['total_amount'],
|
||||
'model_number': item['number'],
|
||||
'single_manufacturing': True,
|
||||
'list_price': item['price'],
|
||||
'materials_id': self.env['sf.production.materials'].search(
|
||||
[('materials_no', '=', item['texture_code'])]).id,
|
||||
@@ -65,6 +69,7 @@ class ResProductTemplate(models.Model):
|
||||
'barcode': item['barcode'],
|
||||
'active': True
|
||||
}
|
||||
logging.info('product_create1:%s' % item)
|
||||
copy_product_id.sudo().write(vals)
|
||||
return copy_product_id
|
||||
|
||||
@@ -109,21 +114,16 @@ class ResMrpBom(models.Model):
|
||||
# 三、胚料的长宽高均要大于模型的长宽高;
|
||||
# 四、如果匹配成功多个胚料,则选取体积最小的胚料;
|
||||
def bom_create_Line(self, product):
|
||||
logging.info('bom_create_Line:%s' % product)
|
||||
embryo = self.env['product.product'].search(
|
||||
[('categ_id.is_embryo', '=', True), ('materials_type_id', '=', product.materials_type_id.id),
|
||||
('long', '>', product.long), ('width', '>', product.width),
|
||||
('length', '>', product.length), ('width', '>', product.width),
|
||||
('height', '>', product.height)
|
||||
],
|
||||
limit=1,
|
||||
order='volume desc'
|
||||
)
|
||||
vals = {
|
||||
'bom_id': self.id,
|
||||
'product_id': embryo.id,
|
||||
'product_tmpl_id': embryo.product_tmpl_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom_id': 1
|
||||
}
|
||||
logging.info('bom_create_Line1:%s' % product)
|
||||
return self.env['mrp.bom.line'].create(vals)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user