优化odoo16工单视图展示问题
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
{
|
||||
'name': '机企猫智能工厂 产品模块',
|
||||
'name': '机企猫智能工厂 产品管理',
|
||||
'version': '1.0',
|
||||
'summary': '智能工厂产品模块',
|
||||
'sequence': 1,
|
||||
@@ -12,7 +12,7 @@
|
||||
'website': 'https://www.sf.jikimo.com',
|
||||
'depends': ['mrp', 'base', 'sf_manufacturing'],
|
||||
'data': [
|
||||
# 'data/product_data.xml',
|
||||
'data/product_data.xml',
|
||||
'views/product_template_view.xml'
|
||||
],
|
||||
'demo': [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<data noupdate="1">
|
||||
<record id="product_template_sf" model="product.product">
|
||||
<field name="name">CNC加工产品模板</field>
|
||||
<field name="categ_id" ref="product.product_category_5"/>
|
||||
<!-- <field name="categ_id" ref="product.product_category_5"/>-->
|
||||
<field name="invoice_policy">delivery</field>
|
||||
<field name="detailed_type">product</field>
|
||||
<field name="purchase_ok">false</field>
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
</field>
|
||||
|
||||
<xpath expr="//label[@for='volume']" position="before">
|
||||
<label for="long" string="尺寸"
|
||||
<label for="length" string="尺寸"
|
||||
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
||||
<div class="o_address_format"
|
||||
attrs="{'invisible':[('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
|
||||
<label for="long" string="长"/>
|
||||
<field name="long" class="o_address_zip"/>
|
||||
<label for="length" string="长"/>
|
||||
<field name="length" class="o_address_zip"/>
|
||||
<span>&nbsp;</span>
|
||||
<label for="width" string="宽"/>
|
||||
<field name="width" class="o_address_zip"/>
|
||||
@@ -34,7 +34,7 @@
|
||||
<field name="model_long" string="长[mm]"/>
|
||||
<field name="model_width" string="宽[mm]"/>
|
||||
<field name="model_height" string="高[mm]"/>
|
||||
<field name="model_volume" string="体积[mm]"/>
|
||||
<field name="model_volume" string="体积[m³]"/>
|
||||
<field name="model_type_id" string="模型类型"/>
|
||||
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"/>
|
||||
<field name="model_machining_precision" />
|
||||
|
||||
Reference in New Issue
Block a user