diff --git a/jikimo_purchase_request/models/purchase_order.py b/jikimo_purchase_request/models/purchase_order.py index 29e6c646..9894f34f 100644 --- a/jikimo_purchase_request/models/purchase_order.py +++ b/jikimo_purchase_request/models/purchase_order.py @@ -94,12 +94,20 @@ class PurchaseOrder(models.Model): def button_cancel(self): """ - 将取消的采购订单关联的库存移动撤销 + 1. 先将采购订单行与目标库存移动断开链接,避免采购单取消后,调拨单被调整为mts的问题 + 2. 取消采购订单 + 3. 将采购订单行与目标库存移动重新建立链接 """ - move_ids = self.order_line.move_dest_ids.filtered(lambda move: move.state != 'done' and not move.scrapped) + created_purchase_request_line_ids = {} + if self.order_line.move_dest_ids.created_purchase_request_line_id: + move_ids = self.order_line.move_dest_ids.filtered(lambda move: move.state != 'done' and not move.scrapped) + created_purchase_request_line_ids = {move.id: move.created_purchase_request_line_id for move in move_ids} + self.order_line.write({'move_dest_ids': [(5, 0, 0)]}) res =super(PurchaseOrder, self).button_cancel() - if move_ids.mapped('created_purchase_request_line_id'): - move_ids.write({'state': 'waiting', 'is_done': False}) + for move_id, created_purchase_request_line_id in created_purchase_request_line_ids.items(): + self.env['stock.move'].browse(move_id).created_purchase_request_line_id = created_purchase_request_line_id + # if move_ids.mapped('created_purchase_request_line_id'): + # move_ids.write({'state': 'waiting', 'is_done': False}) return res def write(self, vals): diff --git a/sf_quality/__manifest__.py b/sf_quality/__manifest__.py index 00cbe496..8b99ce80 100644 --- a/sf_quality/__manifest__.py +++ b/sf_quality/__manifest__.py @@ -22,6 +22,7 @@ 'data/report_actions.xml', 'views/view.xml', 'views/quality_cnc_test_view.xml', + 'views/stock_picking.xml', 'views/mrp_workorder.xml', 'views/quality_check_view.xml', 'views/quality_company.xml', diff --git a/sf_quality/models/stock.py b/sf_quality/models/stock.py index 7b70b77a..8efb1b79 100644 --- a/sf_quality/models/stock.py +++ b/sf_quality/models/stock.py @@ -1,24 +1,29 @@ import logging -from odoo import api, models +from odoo import api, models, fields from odoo.exceptions import ValidationError, UserError class StockPicking(models.Model): _inherit = 'stock.picking' + whether_show_quality_check = fields.Boolean('是否显示质量检测按钮', default=True) + def _compute_check(self): super()._compute_check() for picking in self: picking_to_quality = picking.get_picking_to_quality() if not picking_to_quality: picking.quality_check_todo = False + picking.whether_show_quality_check = False break else: + picking.whether_show_quality_check = True need_quality_line = picking.get_need_quality_line(picking_to_quality) if not need_quality_line or all(not line.get('need_done_check_ids') for line in need_quality_line): picking.quality_check_todo = False + def check_quality(self): self.ensure_one() # checkable_products = self.mapped('move_line_ids').mapped('product_id') diff --git a/sf_quality/views/stock_picking.xml b/sf_quality/views/stock_picking.xml new file mode 100644 index 00000000..857436d8 --- /dev/null +++ b/sf_quality/views/stock_picking.xml @@ -0,0 +1,28 @@ + + + + stock.picking.view.form.sf.quality + stock.picking + + + + + + + {'invisible': ['|', '|','|', ('check_ids', '=', []), ('quality_check_fail', '=', + True), ('quality_check_todo', '!=', True), ('whether_show_quality_check', '!=', True)]} + + + + {'invisible': ['|', '|','|', ('check_ids', '=', []), ('quality_check_fail', '=', + True), ('quality_check_todo', '=', True), ('whether_show_quality_check', '!=', True)]} + + + + {'invisible': ['|', '|',('check_ids', '=', []), ('quality_check_fail', '!=', + True), ('whether_show_quality_check', '!=', True)]} + + + + + \ No newline at end of file