Add option to cancel customer invoice

issue8445
review273511002
This commit is contained in:
Cédric Krier committed 2019-07-22 23:52:26 +02:00
1 parent f5cefe5522
commit 020d3f191c
8 files changed
+47 -2

No files matched your search

+2
View File
@@ -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
+2
View File
@@ -6,6 +6,7 @@ from .payment_term import *
from .invoice import *
from . import party
from .account import *
from . import company
def register():
@@ -36,6 +37,7 @@ def register():
MoveLine,
Reconciliation,
PaymentMethod,
company.Company,
module='account_invoice', type_='model')
Pool.register(
TestPaymentTerm,
+16
View File
@@ -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
+12
View File
@@ -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>
+2 -1
View File
@@ -1423,7 +1423,8 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
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',
+1 -1
View File
@@ -34,7 +34,7 @@ this repository contains the full copyright notices and license terms. -->
<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>
+1
View File
@@ -14,4 +14,5 @@ xml:
payment_term.xml
party.xml
account.xml
company.xml
message.xml
+11
View File
@@ -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>