出厂检验报告需求
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<field name="name">quality.check.measure.line.tree</field>
|
||||
<field name="model">quality.check.measure.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom" class="measureTable" attrs="{ 'pacthResize': True }">
|
||||
<tree editable="bottom" class="measureTable">
|
||||
<!-- <field name="sequence" class="measureTableSequence"/> -->
|
||||
<!-- <field name="column_nums"/> -->
|
||||
<field name="measure_item"/>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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):
|
||||
@@ -209,3 +209,42 @@ class QualityCheck(models.Model):
|
||||
'message': '不合格数量不能超过已检数量'
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -73,9 +73,9 @@
|
||||
<xpath expr="//header" position="inside">
|
||||
<field name="is_out_check" invisible="1"/>
|
||||
<field name="publish_status" invisible="1"/>
|
||||
<button name="%(sf_quality.action_report_quality_inspection_preview)d"
|
||||
<button name="preview_doc"
|
||||
string="预览"
|
||||
type="action"
|
||||
type="object"
|
||||
class="oe_highlight" attrs="{'invisible': [('is_out_check', '=', False)]}"/>
|
||||
<!-- --><!-- 如果还需要打印按钮 -->
|
||||
<!-- <button name="%(sf_quality.action_report_quality_inspection)d" -->
|
||||
@@ -88,10 +88,13 @@
|
||||
<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')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='total_qty']" position="before">
|
||||
<field name="total_qty_readonly" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='total_qty']" position="attributes">
|
||||
<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)],
|
||||
'readonly': [('total_qty_readonly', '=', True)],
|
||||
'on_change': ['|', ('measure_on', '!=', 'move_line'), ('workorder_id', '=', False)]
|
||||
}</attribute>
|
||||
</xpath>
|
||||
|
||||
Reference in New Issue
Block a user