完成 调拨单取消后,关联取消质量检查单
This commit is contained in:
@@ -81,8 +81,29 @@ class StockPicking(models.Model):
|
|||||||
return quality_pickings
|
return quality_pickings
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
|
"""
|
||||||
|
调拨单取消后,关联取消质量检查单
|
||||||
|
"""
|
||||||
|
context = self.env.context
|
||||||
|
if not context.get('cancel_check_picking') and self.sudo().mapped('check_ids').filtered(
|
||||||
|
lambda x: x.quality_state in ['pass', 'fail']):
|
||||||
|
self.env.cr.rollback()
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'res_model': 'picking.check.cancel.wizard',
|
||||||
|
'name': '取消质检单',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
'context': {
|
||||||
|
'default_picking_id': self.id,
|
||||||
|
'cancel_check_picking': True}
|
||||||
|
}
|
||||||
|
elif self.check_ids.filtered(lambda x: x.quality_state != 'cancel'):
|
||||||
|
self.sudo().mapped('check_ids').filtered(lambda x: x.quality_state != 'cancel').write({
|
||||||
|
'quality_state': 'cancel'
|
||||||
|
})
|
||||||
res = super(StockPicking, self).action_cancel()
|
res = super(StockPicking, self).action_cancel()
|
||||||
self.sudo().mapped('check_ids').filtered(lambda x: x.quality_state == 'none').unlink()
|
# self.sudo().mapped('check_ids').filtered(lambda x: x.quality_state == 'none').unlink()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_open_quality_check_picking(self):
|
def action_open_quality_check_picking(self):
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_quality_check_wizard,access.quality_check_wizard,model_quality_check_wizard,quality.group_quality_user,1,1,1,0
|
access_quality_check_wizard,access.quality_check_wizard,model_quality_check_wizard,quality.group_quality_user,1,1,1,0
|
||||||
|
access_picking_check_cancel_wizard,access.picking_check_cancel_wizard,model_picking_check_cancel_wizard,quality.group_quality_user,1,1,1,0
|
||||||
|
|||||||
|
@@ -112,3 +112,18 @@ class QualityCheckWizard(models.TransientModel):
|
|||||||
default_current_check_id=self.current_check_id.id,
|
default_current_check_id=self.current_check_id.id,
|
||||||
)
|
)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
class PickingCheckCancelWizard(models.TransientModel):
|
||||||
|
_name = 'picking.check.cancel.wizard'
|
||||||
|
_description = 'picking check cancel wizard'
|
||||||
|
|
||||||
|
picking_id = fields.Many2one('stock.picking', 'stock picking')
|
||||||
|
|
||||||
|
def confirm_picking_check(self):
|
||||||
|
self.picking_id.action_cancel()
|
||||||
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
||||||
|
def cancel_picking_check(self):
|
||||||
|
# 这里是取消后的逻辑
|
||||||
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|||||||
@@ -118,4 +118,21 @@
|
|||||||
<field name="context">{}</field>
|
<field name="context">{}</field>
|
||||||
<field name="target">new</field>
|
<field name="target">new</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ================================================================================================== -->
|
||||||
|
<record id="picking_check_cancel_wizard_form" model="ir.ui.view">
|
||||||
|
<field name="name">picking.check.cancel.wizard</field>
|
||||||
|
<field name="model">picking.check.cancel.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Quality Check Failed">
|
||||||
|
<div>质量检查单已完成,继续取消吗?</div>
|
||||||
|
<div class="'color': 'red'">注意:关联质量检查单也将被取消。</div>
|
||||||
|
<footer>
|
||||||
|
<button name="confirm_picking_check" type="object" class="btn-primary" string="确认"/>
|
||||||
|
<button name="cancel_picking_check" type="object" string="取消"/>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user