Skip to content

Commit

Permalink
Merge pull request #185 from beescoop/12.0-beesdoo_account-bypass-neg…
Browse files Browse the repository at this point in the history
…ative-invoice

[12.0] beesdoo_account: validate invoice with negative total amount
  • Loading branch information
remytms authored Sep 27, 2020
2 parents d81c214 + 3005dd3 commit 296cd2f
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 13 deletions.
9 changes: 9 additions & 0 deletions beesdoo_account/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ Module that customize account module for Beescoop.
.. contents::
:local:

Configuration
=============

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)

Bug Tracker
===========

Expand Down
1 change: 1 addition & 0 deletions beesdoo_account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
12 changes: 9 additions & 3 deletions beesdoo_account/__manifest__.py
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",
}
2 changes: 2 additions & 0 deletions beesdoo_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_invoice
from . import res_config
38 changes: 38 additions & 0 deletions beesdoo_account/models/account_invoice.py
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()
12 changes: 12 additions & 0 deletions beesdoo_account/models/res_config.py
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""",
)
5 changes: 5 additions & 0 deletions beesdoo_account/readme/CONFIGURE.rst
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)
9 changes: 9 additions & 0 deletions beesdoo_account/security/invoice_security.xml
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>
30 changes: 20 additions & 10 deletions beesdoo_account/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,41 +372,51 @@ <h1 class="title">Beescoop Account Module</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>The setting <em>Validate an invoice with a negative total amount</em> needs to be checked.
This can be done in these following ways:</p>
<ul class="simple">
<li>on the Access Rights (Technical Settings) of the user (Validate an invoice with a negative total amount)</li>
<li>on the Invoicing Settings inside of the section <cite>Invoices</cite> (Allow validating an invoice with a negative total amount)</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/beescoop/obeesdoo/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/beescoop/obeesdoo/issues/new?body=module:%20beesdoo_account%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>Beescoop - Cellule IT</li>
<li>Coop IT Easy SCRLfs</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li>Beescoop - Cellule IT</li>
<li>Coop IT Easy SCRLfs</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is part of the <a class="reference external" href="https://github.com/beescoop/obeesdoo/tree/12.0/beesdoo_account">beescoop/obeesdoo</a> project on GitHub.</p>
<p>You are welcome to contribute.</p>
</div>
Expand Down
23 changes: 23 additions & 0 deletions beesdoo_account/views/res_config_view.xml
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>

0 comments on commit 296cd2f

Please sign in to comment.