Skip to content

Commit

Permalink
[ADD] [15.0]account_invoice_date
Browse files Browse the repository at this point in the history
  • Loading branch information
ikapasi-initos committed Jul 29, 2022
1 parent 31db5af commit 8c77dae
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 0 deletions.
82 changes: 82 additions & 0 deletions account_invoice_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
====================
Account Invoice Date
====================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github
:target: https://github.com/OCA/account-invoicing/tree/15.0/account_invoice_date_due
:alt: OCA/account-invoicing
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-account_invoice_date_due
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/95/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

Usage
=====

When an invoice is validated from Draft to Open automatically, the invoice date is set to current date. If an invoice is validated from Draft to Open manually, a window is displayed to query the invoice date from the user.

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/issues>`_.
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
`feedback <https://github.com/OCA/account-invoicing/issues/new?body=module:%20account_invoice_date_due%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* initOS

Contributors
~~~~~~~~~~~~

* isufi kapasi <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-luisg123v| image:: https://github.com/luisg123v.png?size=40px
:target: https://github.com/luisg123v
:alt: luisg123v
.. |maintainer-joao-p-marques| image:: https://github.com/joao-p-marques.png?size=40px
:target: https://github.com/joao-p-marques
:alt: joao-p-marques

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-luisg123v| |maintainer-joao-p-marques|

This module is part of the `OCA/account-invoicing <https://github.com/OCA/account-invoicing/tree/15.0/account_invoice_date>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions account_invoice_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2022 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models, wizard
24 changes: 24 additions & 0 deletions account_invoice_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# © 2022 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Account Invoice Date",
"summary": """
When an invoice is validated from Draft to Open automatically,
the invoice date is set to current date.
If an invoice is validated from Draft to Open manually,
a window is displayed to query the invoice date from the user.
""",
"category": "Accounting",
"version": "15.0.1.0.0",
"license": "AGPL-3",
"depends": [
"account",
],
"data": [
"security/ir.model.access.csv",
"wizard/account_voucher_proforma_date_view.xml",
"views/account_move_view.xml",
],
"author": "initOS,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-invoicing",
}
4 changes: 4 additions & 0 deletions account_invoice_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2022 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_move
15 changes: 15 additions & 0 deletions account_invoice_date/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from datetime import date

from odoo import models


class AccountMove(models.Model):
_inherit = "account.move"

def action_post(self):
invoice = super(AccountMove, self).action_post()
inv_date = date.today()
if self.env.context.get("invoice_date"):
inv_date = self.env.context.get("invoice_date")
self.write({"invoice_date": inv_date})
return invoice
1 change: 1 addition & 0 deletions account_invoice_date/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* isufi kapasi <[email protected]>
1 change: 1 addition & 0 deletions account_invoice_date/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When an invoice is validated from Draft to Open automatically, the invoice date is set to current date.If an invoice is validated from Draft to Open manually, a window is displayed to query the invoice date from the user.
3 changes: 3 additions & 0 deletions account_invoice_date/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#. Go to Invoice > Click Create > Create new invoice.
#. Click on "Confirm" button.
#. Select the date and Click on "Open invoice" button.
2 changes: 2 additions & 0 deletions account_invoice_date/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
account_invoice_date.access_account_voucher_proforma_date,access_account_voucher_proforma_date,account_invoice_date.model_account_voucher_proforma_date,base.group_user,1,1,1,1
34 changes: 34 additions & 0 deletions account_invoice_date/views/account_move_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_post'][1]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//button[@name='action_post'][2]" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<button name="action_post" position="after">
<button
name="%(account_invoice_date.action_invoice_customer)d"
type="action"
string="Confirm"
class="oe_highlight"
attrs="{'invisible': ['|',('move_type', '!=','out_invoice'),('state','!=','draft')]}"
groups="account.group_account_invoice"
/>
<button
name="%(account_invoice_date.action_credit_invoice_customer)d"
type="action"
string="Confirm"
class="oe_highlight"
attrs="{'invisible': ['|',('move_type', '!=','out_refund'),('state','!=','draft')]}"
groups="account.group_account_invoice"
/>
</button>
</field>
</record>
</odoo>
4 changes: 4 additions & 0 deletions account_invoice_date/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2022 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import account_voucher_proforma_date
25 changes: 25 additions & 0 deletions account_invoice_date/wizard/account_voucher_proforma_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# © 2022 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import fields, models

_logger = logging.getLogger(__name__)


class AccountVoucherProformaDate(models.TransientModel):
_name = "account.voucher.proforma.date"
_description = "Account Voucher Proforma Date"

date = fields.Date(
string="Date of invoice", required=True, default=fields.Date.context_today
)

def action_post(self):
invoice_id = False
if self.env.context.get("active_model") == "account.move":
invoice_id = self.env.context.get("active_id")
assert invoice_id, "Could not determine invoice to open"
invoice = self.env["account.move"].browse(invoice_id)
invoice.with_context(invoice_date=self.date).action_post()
63 changes: 63 additions & 0 deletions account_invoice_date/wizard/account_voucher_proforma_date_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_account_voucher_proforma_date" model="ir.ui.view">
<field name="name">view.account.voucher.proforma.date</field>
<field name="model">account.voucher.proforma.date</field>
<field name="arch" type="xml">
<form>
<group>
<field name="date" string="Please enter invoice date" />
</group>
<footer>
<button
string='Open invoice'
name="action_post"
default_focus="1"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>

<record id="action_invoice_customer" model="ir.actions.act_window">
<field name="name">Open invoice</field>
<field name="res_model">account.voucher.proforma.date</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_voucher_proforma_date" />
<field name="target">new</field>
</record>

<record id="view_account_credit_voucher_proforma_date" model="ir.ui.view">
<field name="name">view.account.credit.voucher.proforma.date</field>
<field name="model">account.voucher.proforma.date</field>
<field name="arch" type="xml">
<form>
<group>
<field name="date" string="Please enter credit note date" />
</group>
<footer>
<button
string='Open credit note'
name="action_post"
type="object"
class="oe_highlight"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>

<record id="action_credit_invoice_customer" model="ir.actions.act_window">
<field name="name">Open credit note</field>
<field name="res_model">account.voucher.proforma.date</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_account_credit_voucher_proforma_date" />
<field name="target">new</field>
</record>
</odoo>
6 changes: 6 additions & 0 deletions setup/account_invoice_date/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 8c77dae

Please sign in to comment.