Accept Merge Request #2101: (feature/6694 -> develop)
Merge Request: 调整质检单字段 Created By: @胡尧 Accepted By: @胡尧 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2101?initial=true
This commit is contained in:
@@ -141,7 +141,7 @@ 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.Char('总数量', compute='_compute_total_qty')
|
total_qty = fields.Char('总数量', compute='_compute_total_qty', store=True)
|
||||||
|
|
||||||
column_nums = fields.Integer('测量值列数', default=1)
|
column_nums = fields.Integer('测量值列数', default=1)
|
||||||
|
|
||||||
@@ -153,9 +153,9 @@ class QualityCheck(models.Model):
|
|||||||
for move in record.picking_id.move_ids_without_package:
|
for move in record.picking_id.move_ids_without_package:
|
||||||
if move.product_id == record.product_id:
|
if move.product_id == record.product_id:
|
||||||
total_qty = int(move.product_uom_qty)
|
total_qty = int(move.product_uom_qty)
|
||||||
record.total_qty = total_qty if total_qty > 0 else ''
|
record.total_qty = total_qty if total_qty > 0 else 0
|
||||||
else:
|
else:
|
||||||
record.total_qty = ''
|
record.total_qty = 0
|
||||||
|
|
||||||
# 检验数
|
# 检验数
|
||||||
check_qty = fields.Integer('检验数', default=lambda self: self._get_default_check_qty())
|
check_qty = fields.Integer('检验数', default=lambda self: self._get_default_check_qty())
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ class QualityCheckWizard(models.TransientModel):
|
|||||||
lot_name = fields.Char(related='current_check_id.lot_name')
|
lot_name = fields.Char(related='current_check_id.lot_name')
|
||||||
lot_line_id = fields.Many2one(related='current_check_id.lot_line_id')
|
lot_line_id = fields.Many2one(related='current_check_id.lot_line_id')
|
||||||
qty_line = fields.Float(related='current_check_id.qty_line')
|
qty_line = fields.Float(related='current_check_id.qty_line')
|
||||||
qty_to_test = fields.Float(related='current_check_id.qty_to_test')
|
qty_to_test = fields.Float(related='current_check_id.qty_to_test', string='待检')
|
||||||
qty_tested = fields.Float(related='current_check_id.qty_tested', readonly=False)
|
qty_tested = fields.Float(related='current_check_id.qty_tested', string='已检', readonly=False)
|
||||||
measure = fields.Float(related='current_check_id.measure', readonly=False)
|
measure = fields.Float(related='current_check_id.measure', readonly=False)
|
||||||
measure_on = fields.Selection(related='current_check_id.measure_on')
|
measure_on = fields.Selection(related='current_check_id.measure_on')
|
||||||
quality_state = fields.Selection(related='current_check_id.quality_state')
|
quality_state = fields.Selection(related='current_check_id.quality_state')
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from odoo import fields, models, api
|
|||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from odoo.addons.sf_base.commons.common import Common
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
|
from odoo.tools import float_round
|
||||||
|
|
||||||
|
|
||||||
class QualityCheck(models.Model):
|
class QualityCheck(models.Model):
|
||||||
@@ -145,39 +146,55 @@ class QualityCheck(models.Model):
|
|||||||
return super(QualityCheck, self).create(vals_list)
|
return super(QualityCheck, self).create(vals_list)
|
||||||
|
|
||||||
|
|
||||||
@api.depends('move_line_id.qty_done', 'workorder_id.qty_produced')
|
@api.depends('total_qty','testing_percentage_within_lot', 'is_lot_tested_fractionally')
|
||||||
def _compute_qty_line(self):
|
def _compute_workorder_qty_to_test(self):
|
||||||
super(QualityCheck, self)._compute_qty_line()
|
for qc in self:
|
||||||
|
if qc.is_lot_tested_fractionally:
|
||||||
|
rounding = qc.product_id.uom_id.rounding if qc.product_id.uom_id else 0.01
|
||||||
|
qc.workorder_qty_to_test = float_round(float(qc.total_qty) * qc.testing_percentage_within_lot / 100,
|
||||||
|
precision_rounding=rounding, rounding_method="UP")
|
||||||
|
else:
|
||||||
|
qc.workorder_qty_to_test = qc.total_qty
|
||||||
|
|
||||||
|
@api.depends('picking_id', 'workorder_id')
|
||||||
|
def _compute_total_qty(self):
|
||||||
|
super(QualityCheck, self)._compute_total_qty()
|
||||||
for qc in self:
|
for qc in self:
|
||||||
if not qc.move_line_id and qc.workorder_id:
|
if not qc.picking_id and qc.workorder_id:
|
||||||
qc.qty_line = qc.workorder_id.production_id.product_qty
|
qc.total_qty = qc.workorder_id.production_id.product_qty
|
||||||
|
|
||||||
qty_line = fields.Float('数量', store=True)
|
@api.depends('workorder_qty_to_test')
|
||||||
qty_test_failed = fields.Float('不合格数')
|
def _compute_workorder_qty_tested(self):
|
||||||
qty_to_test = fields.Float('应检', store=True)
|
for qc in self:
|
||||||
qty_tested = fields.Float('已检')
|
qc.workorder_qty_tested = qc.workorder_qty_to_test
|
||||||
|
|
||||||
@api.onchange('qty_line', 'qty_test_failed', 'qty_to_test', 'qty_tested')
|
|
||||||
|
workorder_qty_to_test = fields.Float('应检', compute='_compute_workorder_qty_to_test', store=True)
|
||||||
|
workorder_qty_tested = fields.Float('已检', compute='_compute_workorder_qty_tested', store=True)
|
||||||
|
workorder_qty_test_failed = fields.Float('不合格数')
|
||||||
|
|
||||||
|
|
||||||
|
@api.onchange('total_qty', 'workorder_qty_test_failed', 'workorder_qty_to_test', 'workorder_qty_tested')
|
||||||
def _onchage_qty(self):
|
def _onchage_qty(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
if record.qty_line and record.qty_to_test and record.qty_to_test > record.qty_line:
|
if record.total_qty and record.workorder_qty_to_test and record.workorder_qty_to_test > float(record.total_qty):
|
||||||
record.qty_to_test = record.qty_line
|
record.workorder_qty_to_test = float(record.total_qty)
|
||||||
return {
|
return {
|
||||||
'warning': {
|
'warning': {
|
||||||
'title': '警告',
|
'title': '警告',
|
||||||
'message': '待检数量不能超过总数量'
|
'message': '待检数量不能超过总数量'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if record.qty_to_test and record.qty_tested and record.qty_tested > record.qty_to_test:
|
if record.workorder_qty_to_test and record.workorder_qty_tested and record.workorder_qty_tested > record.workorder_qty_to_test:
|
||||||
record.qty_tested = record.qty_to_test
|
record.workorder_qty_tested = record.workorder_qty_to_test
|
||||||
return {
|
return {
|
||||||
'warning': {
|
'warning': {
|
||||||
'title': '警告',
|
'title': '警告',
|
||||||
'message': '已检数量不能超过待检数量'
|
'message': '已检数量不能超过待检数量'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if record.qty_tested and record.qty_test_failed and record.qty_test_failed > record.qty_tested:
|
if record.workorder_qty_tested and record.workorder_qty_test_failed and record.workorder_qty_test_failed > record.workorder_qty_tested:
|
||||||
record.qty_test_failed = record.qty_tested
|
record.workorder_qty_test_failed = record.workorder_qty_tested
|
||||||
return {
|
return {
|
||||||
'warning': {
|
'warning': {
|
||||||
'title': '警告',
|
'title': '警告',
|
||||||
|
|||||||
@@ -88,34 +88,41 @@
|
|||||||
<button name="do_cancel_publish" string="取消发布" type="object" class="btn-primary" confirm="确定取消发布吗?" attrs="{'invisible': ['|',('is_out_check', '=', False), ('publish_status', '!=', 'published')]}"/>
|
<button name="do_cancel_publish" string="取消发布" type="object" class="btn-primary" confirm="确定取消发布吗?" attrs="{'invisible': ['|',('is_out_check', '=', False), ('publish_status', '!=', 'published')]}"/>
|
||||||
<button name="do_re_publish" string="重新发布" type="object" class="btn-primary" attrs="{'invisible': ['|', ('is_out_check', '=', False), ('publish_status', '!=', 'canceled')]}"/>
|
<button name="do_re_publish" string="重新发布" type="object" class="btn-primary" attrs="{'invisible': ['|', ('is_out_check', '=', False), ('publish_status', '!=', 'canceled')]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//label[@for='qty_line']" position="attributes">
|
<xpath expr="//field[@name='total_qty']" position="attributes">
|
||||||
<attribute name="attrs">{'invisible': ['&', ('move_line_id', '=', False), ('workorder_id', '=', False)]}</attribute>
|
<attribute name="attrs">{
|
||||||
|
'invisible': ['&', '|', ('measure_on', '!=', 'product'), ('is_out_check', '=', False), '|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)],
|
||||||
|
'readonly': ['|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)],
|
||||||
|
'on_change': ['|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)]
|
||||||
|
}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//div[@class='o_row'][.//field[@name='qty_line']]" position="attributes">
|
<xpath expr="//field[@name='total_qty']" position="after">
|
||||||
<attribute name="attrs">{'invisible': ['&', ('move_line_id', '=', False), ('workorder_id', '=', False)]}</attribute>
|
<label for="workorder_qty_to_test"
|
||||||
</xpath>
|
attrs="{'invisible': ['|', '&', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False), ('is_lot_tested_fractionally', '=', False)]}"/>
|
||||||
<xpath expr="//field[@name='qty_line']" position="attributes">
|
|
||||||
<attribute name="readonly">0</attribute>
|
|
||||||
<attribute name="on_change">1</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//label[@for='qty_to_test']" position="attributes">
|
|
||||||
<attribute name="attrs">{'invisible': ['|', '&', ('move_line_id', '=', False), ('workorder_id', '=', False), '|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False)]}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//div[@class='o_row'][.//field[@name='qty_to_test']]" position="attributes">
|
|
||||||
<attribute name="attrs">{'invisible': ['|', '&', ('move_line_id', '=', False), ('workorder_id', '=', False), '|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False)]}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='qty_to_test']" position="attributes">
|
|
||||||
<attribute name="readonly">0</attribute>
|
|
||||||
<attribute name="on_change">1</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//div[@class='o_row'][.//field[@name='qty_tested']]" position="after">
|
|
||||||
<label for="qty_test_failed"
|
|
||||||
attrs="{'invisible': ['|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False)]}"/>
|
|
||||||
<div class="o_row"
|
<div class="o_row"
|
||||||
attrs="{'invisible': ['|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False)]}">
|
attrs="{'invisible': ['|', '&', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False), ('is_lot_tested_fractionally', '=', False)]}">
|
||||||
<field name="qty_test_failed" attrs="{'readonly': [('quality_state', '!=', 'none')], 'on_chnage': 1}"/>
|
<field name="workorder_qty_to_test" attrs="{'readonly': 0, 'on_chnage': 1}"/>
|
||||||
<field name="uom_id"/>
|
<field name="uom_id"/>
|
||||||
</div>
|
</div>
|
||||||
|
<label for="workorder_qty_tested"
|
||||||
|
attrs="{'invisible': ['|', '&', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False), ('is_lot_tested_fractionally', '=', False)]}"/>
|
||||||
|
<div class="o_row"
|
||||||
|
attrs="{'invisible': ['|', '&', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False), ('is_lot_tested_fractionally', '=', False)]}">
|
||||||
|
<field name="workorder_qty_tested" attrs="{'readonly': [('quality_state', '!=', 'none')], 'on_chnage': 1}"/>
|
||||||
|
<field name="uom_id"/>
|
||||||
|
</div>
|
||||||
|
<label for="workorder_qty_test_failed"
|
||||||
|
attrs="{'invisible': ['|', '&', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False), ('is_lot_tested_fractionally', '=', False)]}"/>
|
||||||
|
<div class="o_row"
|
||||||
|
attrs="{'invisible': ['|', '&', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False), ('is_lot_tested_fractionally', '=', False)]}">
|
||||||
|
<field name="workorder_qty_test_failed" attrs="{'readonly': [('quality_state', '!=', 'none')], 'on_chnage': 1}"/>
|
||||||
|
<field name="uom_id"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//label[@for='qty_tested']" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|', '|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False), '&', ('measure_on', '=', 'move_line'), ('workorder_id', '!=', False)]}</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//div[@class='o_row'][.//field[@name='qty_tested']]" position="attributes">
|
||||||
|
<attribute name="attrs">{'invisible': ['|', '|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False), '&', ('measure_on', '=', 'move_line'), ('workorder_id', '!=', False)]}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user