Skip to content

Commit

Permalink
[10.0][IMP] account_invoice_date_required: Add check as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Mar 14, 2019
1 parent 60635b4 commit bb6912f
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 17 deletions.
10 changes: 9 additions & 1 deletion account_invoice_date_required/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ The invoice validation is now restricted if the invoice date is not filled in.
.. contents::
:local:

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

Go to Accounting > Settings > Invoicing & Payments > Date Required

Check the box if you want to make the invoice date required before
validation.

Usage
=====

Create an invoice with a void date (Invoicing > Sales > Customer Invoices).
Create an invoice with a void date (Accounting > Sales > Customer Invoices).

Try to validate it. An error is raised.

Expand Down
5 changes: 4 additions & 1 deletion account_invoice_date_required/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'summary': """
Requires invoice date before validation to avoid Odoo setting 'today'
as default if not filled in.""",
'version': '10.0.1.0.0',
'version': '10.0.1.1.0',
'development_status': 'Alpha',
'maintainers': ['rousseldenis'],
'category': 'Accounting',
Expand All @@ -17,4 +17,7 @@
'depends': [
'account',
],
'data': [
'views/account_config_settings.xml',
]
}
2 changes: 2 additions & 0 deletions account_invoice_date_required/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import account_invoice
from . import res_company
from . import account_config_settings
15 changes: 15 additions & 0 deletions account_invoice_date_required/models/account_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountConfigSettings(models.TransientModel):

_inherit = 'account.config.settings'

invoice_date_required = fields.Boolean(
related='company_id.invoice_date_required',
string='Invoice Date is Required',
)
4 changes: 3 additions & 1 deletion account_invoice_date_required/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class AccountInvoice(models.Model):

@api.multi
def _check_invoice_date(self):
if self.filtered(lambda i: not i.date_invoice):
if self.filtered(
lambda i: i.company_id.invoice_date_required and
not i.date_invoice):
raise ValidationError(
_('You have to fill in the invoice date before validating'
'the invoice !')
Expand Down
14 changes: 14 additions & 0 deletions account_invoice_date_required/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResCompany(models.Model):

_inherit = 'res.company'

invoice_date_required = fields.Boolean(
string='Invoice Date is Required',
)
4 changes: 4 additions & 0 deletions account_invoice_date_required/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Go to Accounting > Settings > Invoicing & Payments > Date Required

Check the box if you want to make the invoice date required before
validation.
2 changes: 1 addition & 1 deletion account_invoice_date_required/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Create an invoice with a void date (Invoicing > Sales > Customer Invoices).
Create an invoice with a void date (Accounting > Sales > Customer Invoices).

Try to validate it. An error is raised.
33 changes: 20 additions & 13 deletions account_invoice_date_required/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,45 +374,52 @@ <h1 class="title">Account Invoice Date Required</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="id1">Usage</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>
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>Go to Accounting &gt; Settings &gt; Invoicing &amp; Payments &gt; Date Required</p>
<p>Check the box if you want to make the invoice date required before
validation.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
<p>Create an invoice with a void date (Invoicing &gt; Sales &gt; Customer Invoices).</p>
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
<p>Create an invoice with a void date (Accounting &gt; Sales &gt; Customer Invoices).</p>
<p>Try to validate it. An error is raised.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-invoicing/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/OCA/account-invoicing/issues/new?body=module:%20account_invoice_date_required%0Aversion:%2010.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="#id3">Credits</a></h1>
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>ACSONE SA/NV</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Denis Roussel &lt;<a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
Expand Down
11 changes: 11 additions & 0 deletions account_invoice_date_required/tests/test_account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def setUp(self):
'quantity': 1.000,
'price_unit': 2.99})

self.current_user.company_id.invoice_date_required = True

def test_account_invoice_date_required(self):
invoice = self.account_invoice.create({
'partner_id': self.env.ref('base.res_partner_2').id,
Expand All @@ -46,3 +48,12 @@ def test_account_invoice_date_required(self):
'type': 'out_invoice',
'invoice_line_ids': [(6, 0, [self.invoice_line.id])]
}).action_invoice_open()

def test_account_invoice_date_not_required(self):
self.current_user.company_id.invoice_date_required = False
self.account_invoice.create({
'partner_id': self.env.ref('base.res_partner_2').id,
'account_id': self.invoice_account.id,
'type': 'out_invoice',
'invoice_line_ids': [(6, 0, [self.invoice_line.id])]
}).action_invoice_open()
22 changes: 22 additions & 0 deletions account_invoice_date_required/views/account_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>
<record id="view_account_config" model="ir.ui.view">
<field name="name">account settings (in account_invoice_date_required)</field>
<field name="model">account.config.settings</field>
<field name="inherit_id" ref="account.view_account_config_settings"/>
<field name="arch" type="xml">
<xpath expr="//group[div[@name='customer_payments']]" position="after">
<group>
<label for="id" string="Date Required"/>
<div name="date_required">
<label for="invoice_date_required" string="Invoice Date Required"/>
<field name="invoice_date_required"/>
</div>
</group>
</xpath>
</field>
</record>
</odoo>

0 comments on commit bb6912f

Please sign in to comment.