Add mass cancel procurement wizard

This commit is contained in:
Alexis de Lattre
2021-04-26 11:50:11 +02:00
parent ff69a23e17
commit d858634b91
5 changed files with 60 additions and 0 deletions

View File

@@ -1 +1,3 @@
# -*- coding: utf-8 -*-
from . import wizard

View File

@@ -23,6 +23,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
'depends': ['procurement'],
'data': [
'procurement_view.xml',
'wizard/procurement_mass_cancel_view.xml',
],
'installable': True,
}

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import procurement_mass_cancel

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class ProcurementMassCancel(models.TransientModel):
_name = 'procurement.mass.cancel'
_description = 'Procurement Order Mass Cancel'
def run(self):
assert self.env.context.get('active_model') == 'procurement.order'
active_ids = self.env.context.get('active_ids')
assert active_ids
procs = self.env['procurement.order'].browse(active_ids)
procs.cancel() # they already do the filtered on state != done

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2021 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="procurement_mass_cancel_form" model="ir.ui.view">
<field name="model">procurement.mass.cancel</field>
<field name="arch" type="xml">
<form>
<group name="main">
<div>This wizard will cancel the selected procurements which are not already in <i>Done</i> state.</div>
</group>
<footer>
<button type="object" name="run" string="Cancel Procurements" class="btn-primary"/>
<button special="cancel" string="Close" class="btn-default"/>
</footer>
</form>
</field>
</record>
<act_window
id="procurement_mass_cancel_action"
name="Cancel Procurements"
res_model="procurement.mass.cancel"
src_model="procurement.order"
view_mode="form"
target="new"
multi="True"
key2="client_action_multi"
/>
</odoo>