changeset cbfa3e42fe48 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=cbfa3e42fe48
description:
        Use the queue to process reconciled invoices

        We add a process button for account admin to allow the user to force the
        process in case the queued task has failed.

        issue10215
        review361451002
diffstat:

 account.py            |  4 ++--
 invoice.py            |  6 ++++++
 invoice.xml           |  9 +++++++++
 view/invoice_form.xml |  1 +
 4 files changed, 18 insertions(+), 2 deletions(-)

diffs (74 lines):

diff -r ea055cc5009b -r cbfa3e42fe48 account.py
--- a/account.py        Sun Mar 21 16:09:13 2021 +0100
+++ b/account.py        Sun Mar 28 16:22:01 2021 +0200
@@ -327,7 +327,7 @@
     def create(cls, vlist):
         Invoice = Pool().get('account.invoice')
         reconciliations = super(Reconciliation, cls).create(vlist)
-        Invoice.process(list(_invoices_to_process(reconciliations)))
+        Invoice.__queue__.process(list(_invoices_to_process(reconciliations)))
         return reconciliations
 
     @classmethod
@@ -336,7 +336,7 @@
 
         invoices_to_process = _invoices_to_process(reconciliations)
         super(Reconciliation, cls).delete(reconciliations)
-        Invoice.process(list(invoices_to_process))
+        Invoice.__queue__.process(list(invoices_to_process))
 
 
 class RenewFiscalYear(metaclass=PoolMeta):
diff -r ea055cc5009b -r cbfa3e42fe48 invoice.py
--- a/invoice.py        Sun Mar 21 16:09:13 2021 +0100
+++ b/invoice.py        Sun Mar 28 16:22:01 2021 +0200
@@ -325,6 +325,11 @@
                     'invisible': Eval('state') != 'posted',
                     'depends': ['state'],
                     },
+                'process': {
+                    'invisible': ~Eval('state').in_(
+                        ['posted', 'paid']),
+                    'depends': ['state'],
+                    },
                 })
         cls.__rpc__.update({
                 'post': RPC(
@@ -1531,6 +1536,7 @@
         pass
 
     @classmethod
+    @ModelView.button
     def process(cls, invoices):
         paid = []
         posted = []
diff -r ea055cc5009b -r cbfa3e42fe48 invoice.xml
--- a/invoice.xml       Sun Mar 21 16:09:13 2021 +0100
+++ b/invoice.xml       Sun Mar 28 16:22:01 2021 +0200
@@ -214,6 +214,15 @@
             <field name="button" ref="invoice_pay_button"/>
             <field name="group" ref="account.group_account"/>
         </record>
+        <record model="ir.model.button" id="invoice_process_button">
+            <field name="name">process</field>
+            <field name="string">Process</field>
+            <field name="model" search="[('model', '=', 'account.invoice')]"/>
+        </record>
+        <record model="ir.model.button-res.group" 
id="invoice_process_button_group_account_admin">
+            <field name="button" ref="invoice_process_button"/>
+            <field name="group" ref="account.group_account_admin"/>
+        </record>
 
         <record model="ir.action.report" id="report_invoice">
             <field name="name">Invoice</field>
diff -r ea055cc5009b -r cbfa3e42fe48 view/invoice_form.xml
--- a/view/invoice_form.xml     Sun Mar 21 16:09:13 2021 +0100
+++ b/view/invoice_form.xml     Sun Mar 28 16:22:01 2021 +0200
@@ -86,6 +86,7 @@
         <button name="validate_invoice" icon="tryton-forward"/>
         <button name="post" icon="tryton-ok"/>
         <button name="pay" icon="tryton-forward"/>
+        <button name="process" icon="tryton-refresh"/>
     </group>
     <field name="party_lang" invisible="1" colspan="6"/>
 </form>

Reply via email to