-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from beescoop/12.0-beesdoo_account-bypass-neg…
…ative-invoice [12.0] beesdoo_account: validate invoice with negative total amount
- Loading branch information
Showing
10 changed files
with
128 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
# Copyright 2017 - 2020 BEES coop SCRLfs | ||
# - Rémy Taymans <[email protected]> | ||
# - Vincent Van Rossem <[email protected]> | ||
# - 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", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_invoice | ||
from . import res_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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""", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |