控制字段、page显隐逻辑
This commit is contained in:
@@ -125,10 +125,9 @@ class QualityPoint(models.Model):
|
|||||||
|
|
||||||
class QualityCheck(models.Model):
|
class QualityCheck(models.Model):
|
||||||
_inherit = "quality.check"
|
_inherit = "quality.check"
|
||||||
part_name = fields.Char('零件名称', compute='_compute_part_name_number', readonly=True)
|
part_name = fields.Char('零件名称', related='product_id.part_name')
|
||||||
part_number = fields.Char('零件图号', compute='_compute_part_name_number', readonly=True)
|
part_number = fields.Char('零件图号', related='product_id.part_number')
|
||||||
# 材料
|
material_name = fields.Char('材料名称', compute='_compute_material_name')
|
||||||
material_name = fields.Char('材料名称', compute='_compute_material_name', readonly=True)
|
|
||||||
|
|
||||||
# # 总数量,值为调拨单_产品明细_数量
|
# # 总数量,值为调拨单_产品明细_数量
|
||||||
# total_qty = fields.Float('总数量', compute='_compute_total_qty', readonly=True)
|
# total_qty = fields.Float('总数量', compute='_compute_total_qty', readonly=True)
|
||||||
@@ -137,15 +136,37 @@ class QualityCheck(models.Model):
|
|||||||
# # 出厂检验报告编号
|
# # 出厂检验报告编号
|
||||||
# report_number = fields.Char('出厂检验报告编号', compute='_compute_report_number', readonly=True)
|
# report_number = fields.Char('出厂检验报告编号', compute='_compute_report_number', readonly=True)
|
||||||
# 总数量,值为调拨单_产品明细_数量
|
# 总数量,值为调拨单_产品明细_数量
|
||||||
total_qty = fields.Float('总数量', readonly=True)
|
total_qty = fields.Char('总数量', readonly=True)
|
||||||
# 检验数
|
# 检验数
|
||||||
check_qty = fields.Float('检验数', creadonly=True)
|
check_qty = fields.Char('检验数', default=lambda self: self._get_default_check_qty())
|
||||||
|
|
||||||
|
def _get_default_check_qty(self):
|
||||||
|
"""根据条件设置检验数的默认值"""
|
||||||
|
# 这里需要使用_origin来获取已存储的记录,因为新记录在创建时可能还没有这些值
|
||||||
|
if self._origin:
|
||||||
|
if self._origin.measure_on == 'product' and self._origin.test_type_id.name == '出厂检验报告':
|
||||||
|
return ''
|
||||||
|
elif self._origin.measure_on == 'product':
|
||||||
|
return '1'
|
||||||
|
return ''
|
||||||
|
|
||||||
|
@api.onchange('test_type_id', 'measure_on')
|
||||||
|
def _onchange_check_qty(self):
|
||||||
|
"""当测试类型或测量对象变化时,更新检验数"""
|
||||||
|
if self.measure_on == 'product' and self.test_type_id.name == '出厂检验报告':
|
||||||
|
self.check_qty = ''
|
||||||
|
elif self.measure_on == 'product':
|
||||||
|
self.check_qty = '1'
|
||||||
|
|
||||||
# 出厂检验报告编号
|
# 出厂检验报告编号
|
||||||
report_number_id = fields.Many2one('document.document', string='出厂检验报告编号', readonly=True)
|
report_number_id = fields.Many2one('document.document', string='出厂检验报告编号', readonly=True)
|
||||||
is_out_check = fields.Boolean(string='是否出库检验', compute='_compute_is_out_check', readonly=True)
|
is_out_check = fields.Boolean(string='是否出库检验', compute='_compute_is_out_check', readonly=True)
|
||||||
|
|
||||||
measure_line_ids = fields.One2many('quality.check.measure.line', 'check_id', string='测量明细')
|
measure_line_ids = fields.One2many('quality.check.measure.line', 'check_id', string='测量明细')
|
||||||
|
|
||||||
|
categ_type = fields.Selection(string='产品的类别', related='product_id.categ_id.type', store=True)
|
||||||
|
|
||||||
|
|
||||||
def add_measure_line(self):
|
def add_measure_line(self):
|
||||||
"""
|
"""
|
||||||
新增测量值,如果测量值有5列了,则提示“最多只能有5列测量值”
|
新增测量值,如果测量值有5列了,则提示“最多只能有5列测量值”
|
||||||
@@ -164,11 +185,6 @@ class QualityCheck(models.Model):
|
|||||||
pass
|
pass
|
||||||
# self.ensure_one()
|
# self.ensure_one()
|
||||||
|
|
||||||
@depends('product_id')
|
|
||||||
def _compute_part_name_number(self):
|
|
||||||
for record in self:
|
|
||||||
record.part_number = record.product_id.part_number
|
|
||||||
record.part_name = record.product_id.part_name
|
|
||||||
|
|
||||||
@depends('product_id')
|
@depends('product_id')
|
||||||
def _compute_material_name(self):
|
def _compute_material_name(self):
|
||||||
@@ -177,10 +193,10 @@ class QualityCheck(models.Model):
|
|||||||
materials_type_name = record.product_id.materials_type_id.name if record.product_id.materials_type_id else ''
|
materials_type_name = record.product_id.materials_type_id.name if record.product_id.materials_type_id else ''
|
||||||
record.material_name = materials_id_name + ' ' + materials_type_name
|
record.material_name = materials_id_name + ' ' + materials_type_name
|
||||||
|
|
||||||
@depends('point_id')
|
@depends('test_type_id')
|
||||||
def _compute_is_out_check(self):
|
def _compute_is_out_check(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.point_id.title == '出厂检验报告':
|
if record.test_type_id.name == '出厂检验报告':
|
||||||
record.is_out_check = True
|
record.is_out_check = True
|
||||||
else:
|
else:
|
||||||
record.is_out_check = False
|
record.is_out_check = False
|
||||||
|
|||||||
@@ -265,12 +265,14 @@
|
|||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
|
<field name="categ_type" invisible="1"/>
|
||||||
<field name="product_id" attrs="{'invisible' : [('measure_on', '=', 'operation')]}"/>
|
<field name="product_id" attrs="{'invisible' : [('measure_on', '=', 'operation')]}"/>
|
||||||
<field name="part_name"/>
|
<field name="part_name" attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||||
<field name="part_number"/>
|
<field name="part_number" attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||||
<field name="material_name"/>
|
<field name="material_name" attrs="{'invisible': [('categ_type', '!=', '成品')]}"/>
|
||||||
<field name="total_qty"/>
|
<field name="total_qty" attrs="{'invisible': ['|', ('measure_on', '!=', 'product'), ('is_out_check', '=', False)]}"/>
|
||||||
<field name="check_qty"/>
|
<field name="check_qty" attrs="{'invisible': [('measure_on', '!=', 'product')]}"/>
|
||||||
|
<!-- <field name="categ_type"/> -->
|
||||||
<!-- <field name="report_number"/> -->
|
<!-- <field name="report_number"/> -->
|
||||||
<field name="show_lot_text" invisible="1"/>
|
<field name="show_lot_text" invisible="1"/>
|
||||||
<field name="move_line_id" invisible="1"/>
|
<field name="move_line_id" invisible="1"/>
|
||||||
@@ -343,14 +345,6 @@
|
|||||||
<page string="出厂检验报告" name="out_check" attrs="{'invisible': [('is_out_check', '=', False)]}">
|
<page string="出厂检验报告" name="out_check" attrs="{'invisible': [('is_out_check', '=', False)]}">
|
||||||
<!-- <field name="report_number"/> -->
|
<!-- <field name="report_number"/> -->
|
||||||
</page>
|
</page>
|
||||||
<page string="2D加工图纸" name="2d_drawing" attrs="{'invisible': [('is_out_check', '=', False)]}">
|
|
||||||
<!-- <field name="2d_drawing"/> -->
|
|
||||||
</page>
|
|
||||||
<page string="质检标准" name="quality_standard" attrs="{'invisible': [('is_out_check', '=', False)]}">
|
|
||||||
<!-- <field name="quality_standard"/> -->
|
|
||||||
</page>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<page string="Notes" name="notes">
|
<page string="Notes" name="notes">
|
||||||
<group>
|
<group>
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
<record id="quality_point_out_check_report" model="quality.point">
|
<record id="test_type_factory_inspection" model="quality.point.test_type">
|
||||||
<field name="title">出厂检验报告</field>
|
<field name="name">出厂检验报告</field>
|
||||||
<field name="picking_type_ids" eval="[(4, ref('stock.picking_type_out'))]"/> <!-- 作业类型:发料出库 -->
|
<field name="technical_name">factory_inspection</field>
|
||||||
<field name="measure_on">product</field> <!-- 控制方式:产品 -->
|
|
||||||
<field name="measure_frequency_type">all</field> <!-- 控制频率:全部 -->
|
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from odoo import models, fields
|
from odoo import models, fields, api
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
class SfQualityPoint(models.Model):
|
class SfQualityPoint(models.Model):
|
||||||
_inherit = 'quality.point'
|
_inherit = 'quality.point'
|
||||||
@@ -16,4 +16,14 @@ class SfQualityPoint(models.Model):
|
|||||||
operation_id = fields.Many2one(
|
operation_id = fields.Many2one(
|
||||||
'mrp.routing.workcenter', 'Step', check_company=True,
|
'mrp.routing.workcenter', 'Step', check_company=True,
|
||||||
domain="[('is_outsource', '=', False),('company_id', 'in', (company_id, False))]")
|
domain="[('is_outsource', '=', False),('company_id', 'in', (company_id, False))]")
|
||||||
|
|
||||||
|
@api.onchange('test_type_id')
|
||||||
|
def _onchange_test_type_id(self):
|
||||||
|
"""
|
||||||
|
如果类型选择了出厂检验报告,检查measure_on的值是否为product,如果为product,则类型的值不变,如果
|
||||||
|
不是,则提示错误
|
||||||
|
"""
|
||||||
|
if self.test_type_id.name == '出厂检验报告':
|
||||||
|
if self.measure_on != 'product':
|
||||||
|
raise ValidationError('出厂检验报告的测量对象必须为产品')
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,11 @@
|
|||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="2D图纸" attrs="{'invisible': [('production_id', '=', False)]}">
|
<page string="2D加工图纸" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])]}">
|
||||||
<field name="machining_drawings" string="" widget="adaptive_viewer"/>
|
<field name='machining_drawings' widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="客户质量标准" attrs="{'invisible': [('production_id', '=', False)]}">
|
<page string="质检标准" attrs="{'invisible': [('categ_type', 'not in', ['成品', '坯料'])]}">
|
||||||
<field name="quality_standard" string="" widget="adaptive_viewer"/>
|
<field name='quality_standard' widget="adaptive_viewer"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="其他"
|
<page string="其他"
|
||||||
attrs="{'invisible': ['|',('quality_state', 'not in', ['pass', 'fail']), ('production_id', '=', False)]}">
|
attrs="{'invisible': ['|',('quality_state', 'not in', ['pass', 'fail']), ('production_id', '=', False)]}">
|
||||||
|
|||||||
Reference in New Issue
Block a user