diff --git a/quality_control/views/quality.check.measures.line.xml b/quality_control/views/quality.check.measures.line.xml
index 1e37334a..e15a853f 100644
--- a/quality_control/views/quality.check.measures.line.xml
+++ b/quality_control/views/quality.check.measures.line.xml
@@ -4,7 +4,7 @@
quality.check.measure.line.tree
quality.check.measure.line
-
+
diff --git a/sf_quality/__manifest__.py b/sf_quality/__manifest__.py
index 902deffa..00cbe496 100644
--- a/sf_quality/__manifest__.py
+++ b/sf_quality/__manifest__.py
@@ -13,7 +13,7 @@
'author': 'jikimo',
'website': 'https://sf.cs.jikimo.com',
# 此处依赖sf_manufacturing是因为我要重写其中的一个字段operation_id的string,故需要sf_manufacturing先安装
- 'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing','jikimo_attachment_viewer'],
+ 'depends': ['quality_control', 'web_widget_model_viewer', 'sf_manufacturing','jikimo_attachment_viewer', 'jikimo_confirm_dialog'],
'data': [
'security/ir.model.access.csv',
'data/check_standards.xml',
diff --git a/sf_quality/models/quality.py b/sf_quality/models/quality.py
index 7e058409..88a5fccb 100644
--- a/sf_quality/models/quality.py
+++ b/sf_quality/models/quality.py
@@ -5,7 +5,7 @@ from odoo import fields, models, api
from odoo.exceptions import ValidationError
from datetime import datetime
from odoo.addons.sf_base.commons.common import Common
-from odoo.tools import float_round
+from odoo.tools import float_round, float_compare
class QualityCheck(models.Model):
@@ -208,4 +208,43 @@ class QualityCheck(models.Model):
'title': '警告',
'message': '不合格数量不能超过已检数量'
}
- }
\ No newline at end of file
+ }
+
+ total_qty_readonly = fields.Boolean(compute='_compute_total_qty_readonly', store=True)
+
+ def _compute_total_qty_readonly(self):
+ report_test_type_id = self.env.ref('sf_quality.test_type_factory_inspection').id
+ for record in self:
+ if (record.measure_on != 'move_line' or record.workorder_id is False) and record.point_id.test_type_id.id != report_test_type_id:
+ record.total_qty_readonly = True
+ else:
+ record.total_qty_readonly = False
+
+ def preview_doc(self):
+ """预览出厂检验报告"""
+ self.ensure_one()
+ picking_qty = sum(self.picking_id.move_ids.mapped('product_uom_qty'))
+ if float_compare(float(self.total_qty), picking_qty, self.picking_id.product_id.uom_id.rounding) != 0:
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'jikimo_confirm_dialog',
+ 'params': {
+ 'active_id': self.id,
+ 'message': f"拣货调拨单号{self.picking_id.name}需求数量为{picking_qty},当前质量检查单产品数量为{self.total_qty},数量不一致,是否确认继续?",
+ 'next_model': self._name,
+ 'next_method': 'preview_doc_confirm',
+ 'context': self.env.context
+ }
+ }
+ action = self.env.ref("sf_quality.action_report_quality_inspection_preview").read()[0]
+ return action
+
+
+ def preview_doc_confirm(self):
+ self.ensure_one()
+ action = self.env.ref("sf_quality.action_report_quality_inspection_preview").read()[0]
+ action['context'] = {
+ 'active_id': self.id,
+ 'active_ids': [self.id]
+ }
+ return action
diff --git a/sf_quality/views/quality_check_view.xml b/sf_quality/views/quality_check_view.xml
index 69e1875f..eb9ffb77 100644
--- a/sf_quality/views/quality_check_view.xml
+++ b/sf_quality/views/quality_check_view.xml
@@ -73,9 +73,9 @@
-
@@ -88,10 +88,13 @@
+
+
+
{
'invisible': ['&', '|', ('measure_on', '!=', 'product'), ('is_out_check', '=', False), '|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)],
- 'readonly': ['|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)],
+ 'readonly': [('total_qty_readonly', '=', True)],
'on_change': ['|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)]
}