changeset a83ef0738e63 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=a83ef0738e63
description:
        Add option to cancel customer invoice

        issue8445
        review273511002
diffstat:

 CHANGELOG             |   2 ++
 __init__.py           |   2 ++
 company.py            |  16 ++++++++++++++++
 company.xml           |  12 ++++++++++++
 invoice.py            |   3 ++-
 message.xml           |   2 +-
 tryton.cfg            |   1 +
 view/company_form.xml |  11 +++++++++++
 8 files changed, 47 insertions(+), 2 deletions(-)

diffs (113 lines):

diff -r ba6567bf8e48 -r a83ef0738e63 CHANGELOG
--- a/CHANGELOG Fri Jul 05 08:58:35 2019 +0200
+++ b/CHANGELOG Mon Jul 22 23:52:26 2019 +0200
@@ -1,3 +1,5 @@
+* Add option to cancel customer invoice
+
 Version 5.2.0 - 2019-05-06
 * Bug fixes (see mercurial logs for details)
 * Show reconciliation lines as payment lines
diff -r ba6567bf8e48 -r a83ef0738e63 __init__.py
--- a/__init__.py       Fri Jul 05 08:58:35 2019 +0200
+++ b/__init__.py       Mon Jul 22 23:52:26 2019 +0200
@@ -6,6 +6,7 @@
 from .invoice import *
 from . import party
 from .account import *
+from . import company
 
 
 def register():
@@ -36,6 +37,7 @@
         MoveLine,
         Reconciliation,
         PaymentMethod,
+        company.Company,
         module='account_invoice', type_='model')
     Pool.register(
         TestPaymentTerm,
diff -r ba6567bf8e48 -r a83ef0738e63 company.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/company.py        Mon Jul 22 23:52:26 2019 +0200
@@ -0,0 +1,16 @@
+# This file is part of Tryton.  The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from trytond.model import fields
+from trytond.pool import PoolMeta
+
+
+class Company(metaclass=PoolMeta):
+    __name__ = 'company.company'
+
+    cancel_invoice_out = fields.Boolean(
+        "Cancel Customer Invoice",
+        help="Allow cancelling move of customer invoice.")
+
+    @classmethod
+    def default_cancel_invoice_out(cls):
+        return False
diff -r ba6567bf8e48 -r a83ef0738e63 company.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/company.xml       Mon Jul 22 23:52:26 2019 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+    <data>
+        <record model="ir.ui.view" id="company_view_form">
+            <field name="model">company.company</field>
+            <field name="inherit" ref="company.company_view_form"/>
+            <field name="name">company_form</field>
+        </record>
+    </data>
+</tryton>
diff -r ba6567bf8e48 -r a83ef0738e63 invoice.py
--- a/invoice.py        Fri Jul 05 08:58:35 2019 +0200
+++ b/invoice.py        Mon Jul 22 23:52:26 2019 +0200
@@ -1423,7 +1423,8 @@
                 if invoice.move.state == 'draft':
                     delete_moves.append(invoice.move)
                 elif not invoice.cancel_move:
-                    if invoice.type == 'out':
+                    if (invoice.type == 'out'
+                            and not invoice.company.cancel_invoice_out):
                         raise AccessError(
                             gettext('account_invoice'
                                 '.msg_invoice_customer_cancel_move',
diff -r ba6567bf8e48 -r a83ef0738e63 message.xml
--- a/message.xml       Fri Jul 05 08:58:35 2019 +0200
+++ b/message.xml       Mon Jul 22 23:52:26 2019 +0200
@@ -34,7 +34,7 @@
             <field name="text">You cannot delete invoice "%(invoice)s" because 
it has a number.</field>
         </record>
         <record model="ir.message" id="msg_invoice_customer_cancel_move">
-            <field name="text">You cannot cancel customer invoice 
"%(invoice)s" because it is posted.</field>
+            <field name="text">You cannot cancel customer invoice 
"%(invoice)s" because it is posted and company setup does not allow it.</field>
         </record>
         <record model="ir.message" 
id="msg_invoice_payment_lines_greater_amount">
             <field name="text">Payment lines amount on invoice "%(invoice)s" 
can not be greater than the invoice amount.</field>
diff -r ba6567bf8e48 -r a83ef0738e63 tryton.cfg
--- a/tryton.cfg        Fri Jul 05 08:58:35 2019 +0200
+++ b/tryton.cfg        Mon Jul 22 23:52:26 2019 +0200
@@ -14,4 +14,5 @@
     payment_term.xml
     party.xml
     account.xml
+    company.xml
     message.xml
diff -r ba6567bf8e48 -r a83ef0738e63 view/company_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/view/company_form.xml     Mon Jul 22 23:52:26 2019 +0200
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+    <xpath expr="/form/notebook" position="inside">
+        <page string="Invoice" id="invoice">
+            <label name="cancel_invoice_out"/>
+            <field name="cancel_invoice_out"/>
+        </page>
+    </xpath>
+</data>

Reply via email to