Accept Merge Request #2161: (feature/6694 -> develop)
Merge Request: 出厂检验报告发布按钮增加判断 Created By: @胡尧 Accepted By: @胡尧 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2161?initial=true
This commit is contained in:
@@ -224,7 +224,7 @@ class QualityCheck(models.Model):
|
||||
"""预览出厂检验报告"""
|
||||
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:
|
||||
if not self._check_total_qty(picking_qty) and self.quality_state in ['waiting', 'none']:
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'jikimo_confirm_dialog',
|
||||
@@ -248,3 +248,55 @@ class QualityCheck(models.Model):
|
||||
'active_ids': [self.id]
|
||||
}
|
||||
return action
|
||||
|
||||
def _check_total_qty(self, compare_qty):
|
||||
"""
|
||||
检查质量检查单的总数量是否匹配
|
||||
"""
|
||||
self.ensure_one()
|
||||
return float_compare(float(self.total_qty), compare_qty, self.picking_id.product_id.uom_id.rounding) == 0
|
||||
|
||||
|
||||
def preview_do_publish(self):
|
||||
self.ensure_one()
|
||||
self._check_part_number()
|
||||
self._check_measure_line()
|
||||
self._check_check_qty_and_total_qty()
|
||||
|
||||
picking_qty = sum(self.picking_id.move_ids.mapped('product_uom_qty'))
|
||||
if not self._check_total_qty(picking_qty):
|
||||
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_do_publish_confirm',
|
||||
'context': self.env.context
|
||||
}
|
||||
}
|
||||
else:
|
||||
return self.do_publish()
|
||||
|
||||
|
||||
def preview_do_publish_confirm(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'name': '发布确认',
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'quality.check.publish.wizard',
|
||||
'view_mode': 'form',
|
||||
'views': [[False, 'form']],
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_check_id': self.id,
|
||||
'default_product_name': self.product_id.name,
|
||||
'default_total_qty': self.total_qty,
|
||||
'default_check_qty': self.check_qty,
|
||||
'default_measure_count': self.column_nums,
|
||||
'default_item_count': len(self.measure_line_ids),
|
||||
'default_old_report_name': self.old_report_name,
|
||||
'default_publish_status': self.publish_status,
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@
|
||||
<!-- string="打印报告" -->
|
||||
<!-- type="action"/> -->
|
||||
<!-- <button name="do_preview" string="预览" type="object" class="btn-primary" attrs="{'invisible': [('is_out_check', '=', False)]}"/> -->
|
||||
<button name="do_publish" string="发布" type="object" class="btn-primary" attrs="{'invisible': ['|', ('is_out_check', '=', False), ('publish_status', '!=', 'draft')]}"/>
|
||||
<button name="preview_do_publish" string="发布" type="object" class="btn-primary" attrs="{'invisible': ['|', ('is_out_check', '=', False), ('publish_status', '!=', 'draft')]}"/>
|
||||
<!-- <button name="get_report_url" string="ceshi" type="object" class="btn-primary"/> -->
|
||||
<!-- <button name="upload_factory_report" string="upload_factory_report" type="object" class="btn-primary"/> -->
|
||||
<button name="do_cancel_publish" string="取消发布" type="object" class="btn-primary" confirm="确定取消发布吗?" attrs="{'invisible': ['|',('is_out_check', '=', False), ('publish_status', '!=', 'published')]}"/>
|
||||
|
||||
Reference in New Issue
Block a user