质检单数量约束
This commit is contained in:
@@ -155,4 +155,32 @@ class QualityCheck(models.Model):
|
||||
qty_line = fields.Float('数量', store=True)
|
||||
qty_test_failed = fields.Float('不合格数')
|
||||
qty_to_test = fields.Float('应检', store=True)
|
||||
qty_tested = fields.Float('已检')
|
||||
qty_tested = fields.Float('已检')
|
||||
|
||||
@api.onchange('qty_line', 'qty_test_failed', 'qty_to_test', 'qty_tested')
|
||||
def _onchage_qty(self):
|
||||
for record in self:
|
||||
if record.qty_line and record.qty_to_test and record.qty_to_test > record.qty_line:
|
||||
record.qty_to_test = record.qty_line
|
||||
return {
|
||||
'warning': {
|
||||
'title': '警告',
|
||||
'message': '待检数量不能超过总数量'
|
||||
}
|
||||
}
|
||||
if record.qty_to_test and record.qty_tested and record.qty_tested > record.qty_to_test:
|
||||
record.qty_tested = record.qty_to_test
|
||||
return {
|
||||
'warning': {
|
||||
'title': '警告',
|
||||
'message': '已检数量不能超过待检数量'
|
||||
}
|
||||
}
|
||||
if record.qty_tested and record.qty_test_failed and record.qty_test_failed > record.qty_tested:
|
||||
record.qty_test_failed = record.qty_tested
|
||||
return {
|
||||
'warning': {
|
||||
'title': '警告',
|
||||
'message': '不合格数量不能超过已检数量'
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,7 @@
|
||||
</xpath>
|
||||
<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>
|
||||
@@ -105,13 +106,14 @@
|
||||
</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"
|
||||
attrs="{'invisible': ['|', ('measure_on', '!=', 'move_line'), ('is_lot_tested_fractionally', '=', False)]}">
|
||||
<field name="qty_test_failed" attrs="{'readonly': [('quality_state', '!=', 'none')]}"/>
|
||||
<field name="qty_test_failed" attrs="{'readonly': [('quality_state', '!=', 'none')], 'on_chnage': 1}"/>
|
||||
<field name="uom_id"/>
|
||||
</div>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user