Browse Source
Merge pull request #185 from beescoop/12.0-beesdoo_account-bypass-negative-invoice
Merge pull request #185 from beescoop/12.0-beesdoo_account-bypass-negative-invoice
[12.0] beesdoo_account: validate invoice with negative total amountpull/188/merge 12.0-2020-09-27.00
Rémy Taymans
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 128 additions and 13 deletions
-
9beesdoo_account/README.rst
-
1beesdoo_account/__init__.py
-
12beesdoo_account/__manifest__.py
-
2beesdoo_account/models/__init__.py
-
38beesdoo_account/models/account_invoice.py
-
12beesdoo_account/models/res_config.py
-
5beesdoo_account/readme/CONFIGURE.rst
-
9beesdoo_account/security/invoice_security.xml
-
30beesdoo_account/static/description/index.html
-
23beesdoo_account/views/res_config_view.xml
@ -0,0 +1 @@ |
|||
from . import models |
@ -1,19 +1,25 @@ |
|||
# Copyright 2017 - 2020 BEES coop SCRLfs |
|||
# - Rémy Taymans <remy@coopiteasy.be> |
|||
# - Vincent Van Rossem <vincent@coopiteasy.be> |
|||
# - Elise Dupont |
|||
# - Augustin Borsu |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
{ |
|||
"name": "Beescoop Account Module", |
|||
"summary": """ |
|||
Makes date_invoice field required in account.invoice_form and |
|||
- Makes date_invoice field required in account.invoice_form and |
|||
account.invoice_supplier_form |
|||
- Allow validating an invoice with a negative total amount |
|||
""", |
|||
"author": "Beescoop - Cellule IT, Coop IT Easy SCRLfs", |
|||
"website": "https://github.com/beescoop/Obeesdoo", |
|||
"category": "Account Module", |
|||
"version": "12.0.1.0.0", |
|||
"version": "12.0.1.1.0", |
|||
"depends": ["account", "beesdoo_base"], |
|||
"data": ["views/account_invoice.xml"], |
|||
"data": [ |
|||
"security/invoice_security.xml", |
|||
"views/account_invoice.xml", |
|||
"views/res_config_view.xml", |
|||
], |
|||
"license": "AGPL-3", |
|||
} |
@ -0,0 +1,2 @@ |
|||
from . import account_invoice |
|||
from . import res_config |
@ -0,0 +1,38 @@ |
|||
from odoo import api, fields, models, _ |
|||
from odoo.exceptions import UserError |
|||
|
|||
|
|||
class AccountInvoice(models.Model): |
|||
_inherit = "account.invoice" |
|||
|
|||
@api.multi |
|||
def action_invoice_open(self): |
|||
if self.user_has_groups( |
|||
"beesdoo_account." "group_validate_invoice_negative_total_amount" |
|||
): |
|||
return self.action_invoice_negative_amount_open() |
|||
return super(AccountInvoice, self).action_invoice_open() |
|||
|
|||
@api.multi |
|||
def action_invoice_negative_amount_open(self): |
|||
"""Identical to action_invoice_open without UserError on an invoice with a negative total amount""" |
|||
to_open_invoices = self.filtered(lambda inv: inv.state != "open") |
|||
if to_open_invoices.filtered(lambda inv: not inv.partner_id): |
|||
raise UserError( |
|||
_( |
|||
"The field Vendor is required, please complete it to validate the Vendor Bill." |
|||
) |
|||
) |
|||
if to_open_invoices.filtered(lambda inv: inv.state != "draft"): |
|||
raise UserError( |
|||
_("Invoice must be in draft state in order to validate it.") |
|||
) |
|||
if to_open_invoices.filtered(lambda inv: not inv.account_id): |
|||
raise UserError( |
|||
_( |
|||
"No account was found to create the invoice, be sure you have installed a chart of account." |
|||
) |
|||
) |
|||
to_open_invoices.action_date_assign() |
|||
to_open_invoices.action_move_create() |
|||
return to_open_invoices.invoice_validate() |
@ -0,0 +1,12 @@ |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class ResConfigSettings(models.TransientModel): |
|||
_inherit = "res.config.settings" |
|||
|
|||
group_validate_invoice_negative_total_amount = fields.Boolean( |
|||
"""Allow validating an invoice with a negative total amount""", |
|||
implied_group="beesdoo_account." |
|||
"group_validate_invoice_negative_total_amount", |
|||
help="""Allows you to validate an invoice with a negative total amount""", |
|||
) |
@ -0,0 +1,5 @@ |
|||
The setting *Validate an invoice with a negative total amount* needs to be checked. |
|||
This can be done in these following ways: |
|||
|
|||
* on the Access Rights (Technical Settings) of the user (Validate an invoice with a negative total amount) |
|||
* on the Invoicing Settings inside of the section `Invoices` (Allow validating an invoice with a negative total amount) |
@ -0,0 +1,9 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<odoo> |
|||
<record id="group_validate_invoice_negative_total_amount" model="res.groups"> |
|||
<field |
|||
name="name">Validate an invoice with a negative total amount</field> |
|||
<field name="category_id" ref="base.module_category_hidden"/> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,23 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<odoo> |
|||
<record id="res_config_settings_view_form" model="ir.ui.view"> |
|||
<field name="name">res invoice negative total amount settings</field> |
|||
<field name="model">res.config.settings</field> |
|||
<field name="inherit_id" ref="account.res_config_settings_view_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath |
|||
expr="//div[@id='invoicing_settings']" |
|||
position="inside"> |
|||
<div class="col-xs-12 col-md-6 o_setting_box"> |
|||
<div class="o_setting_left_pane"> |
|||
<field name="group_validate_invoice_negative_total_amount"/> |
|||
</div> |
|||
<div class="o_setting_right_pane"> |
|||
<label for="group_validate_invoice_negative_total_amount"/> |
|||
</div> |
|||
</div> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue