Browse Source

Merge pull request #185 from beescoop/12.0-beesdoo_account-bypass-negative-invoice

[12.0] beesdoo_account: validate invoice with negative total amount
pull/188/merge 12.0-2020-09-27.00
Rémy Taymans 4 years ago
committed by GitHub
parent
commit
296cd2fdd3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      beesdoo_account/README.rst
  2. 1
      beesdoo_account/__init__.py
  3. 12
      beesdoo_account/__manifest__.py
  4. 2
      beesdoo_account/models/__init__.py
  5. 38
      beesdoo_account/models/account_invoice.py
  6. 12
      beesdoo_account/models/res_config.py
  7. 5
      beesdoo_account/readme/CONFIGURE.rst
  8. 9
      beesdoo_account/security/invoice_security.xml
  9. 30
      beesdoo_account/static/description/index.html
  10. 23
      beesdoo_account/views/res_config_view.xml

9
beesdoo_account/README.rst

@ -26,6 +26,15 @@ Module that customize account module for Beescoop.
.. contents:: .. contents::
:local: :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 Bug Tracker
=========== ===========

1
beesdoo_account/__init__.py

@ -0,0 +1 @@
from . import models

12
beesdoo_account/__manifest__.py

@ -1,19 +1,25 @@
# Copyright 2017 - 2020 BEES coop SCRLfs # Copyright 2017 - 2020 BEES coop SCRLfs
# - Rémy Taymans <remy@coopiteasy.be> # - Rémy Taymans <remy@coopiteasy.be>
# - Vincent Van Rossem <vincent@coopiteasy.be>
# - Elise Dupont # - Elise Dupont
# - Augustin Borsu # - Augustin Borsu
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Beescoop Account Module", "name": "Beescoop Account Module",
"summary": """ "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 account.invoice_supplier_form
- Allow validating an invoice with a negative total amount
""", """,
"author": "Beescoop - Cellule IT, Coop IT Easy SCRLfs", "author": "Beescoop - Cellule IT, Coop IT Easy SCRLfs",
"website": "https://github.com/beescoop/Obeesdoo", "website": "https://github.com/beescoop/Obeesdoo",
"category": "Account Module", "category": "Account Module",
"version": "12.0.1.0.0",
"version": "12.0.1.1.0",
"depends": ["account", "beesdoo_base"], "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", "license": "AGPL-3",
} }

2
beesdoo_account/models/__init__.py

@ -0,0 +1,2 @@
from . import account_invoice
from . import res_config

38
beesdoo_account/models/account_invoice.py

@ -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
beesdoo_account/models/res_config.py

@ -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
beesdoo_account/readme/CONFIGURE.rst

@ -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
beesdoo_account/security/invoice_security.xml

@ -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
beesdoo_account/static/description/index.html

@ -372,17 +372,27 @@ ul.auto-toc {
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <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> </ul>
</li> </li>
</ul> </ul>
</div> </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"> <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>. <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. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
@ -390,23 +400,23 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <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"> <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"> <ul class="simple">
<li>Beescoop - Cellule IT</li> <li>Beescoop - Cellule IT</li>
<li>Coop IT Easy SCRLfs</li> <li>Coop IT Easy SCRLfs</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <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"> <ul class="simple">
<li>Beescoop - Cellule IT</li> <li>Beescoop - Cellule IT</li>
<li>Coop IT Easy SCRLfs</li> <li>Coop IT Easy SCRLfs</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <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>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> <p>You are welcome to contribute.</p>
</div> </div>

23
beesdoo_account/views/res_config_view.xml

@ -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>
Loading…
Cancel
Save