Skip to content

Commit

Permalink
[ADD] account_invoice_date
Browse files Browse the repository at this point in the history
  • Loading branch information
dsolanki-initos committed Feb 21, 2023
1 parent 71af99f commit 402da0b
Show file tree
Hide file tree
Showing 15 changed files with 319 additions and 0 deletions.
71 changes: 71 additions & 0 deletions account_invoice_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
====================
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 customer invoice or vendor bill is validated from Draft to Open automatically, the invoice/bill date is set to current date. If an invoice/bill is validated from Draft to Open manually, a window is displayed to query the invoice/bill 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.

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 or bill is validated from Draft to Open automatically,
the invoice/bill date is set to current date.
If an invoice/bill is validated from Draft to Open manually,
a window is displayed to query the invoice/bill 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
38 changes: 38 additions & 0 deletions account_invoice_date/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from datetime import date

from odoo import models


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

def action_post(self):
if not self.move_type == "in_invoice":
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})
if self.move_type == "in_invoice":
invoice = super(AccountMove, self).action_post()
return invoice

def open_invoice_date_wizard(self):
if self.invoice_date:
self.action_post()
else:
if self.move_type == "out_invoice":
name = "Confirm Invoice"
else:
name = "Confirm Bill"
action = self.env.ref(
"account_invoice_date.view_account_voucher_proforma_date"
)
return {
"name": name,
"view_type": "form",
"target": "new",
"res_model": "account.voucher.proforma.date",
"views": [(action.id, "form")],
"type": "ir.actions.act_window",
}
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
42 changes: 42 additions & 0 deletions account_invoice_date/views/account_move_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?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="open_invoice_date_wizard"
type="object"
string="Confirm"
class="oe_highlight"
attrs="{'invisible': ['|', '|', ('state', '!=', 'draft'), ('auto_post', '=', True), ('move_type', '!=', 'entry')]}"
groups="account.group_account_invoice"
/>
<button
name="open_invoice_date_wizard"
string="Confirm"
class="oe_highlight"
type="object"
groups="account.group_account_invoice"
attrs="{'invisible': ['|', '|', '|', ('state', '!=', 'draft'), ('auto_post', '=',True),('move_type','=','entry'),('display_inactive_currency_warning','=',True)]}"
/>
<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'),('invoice_date', '!=', False)]}"
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
35 changes: 35 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,35 @@
# © 2022 Thomas Rehn (initOS GmbH)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import api, 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
)
invoice_type = fields.Char()

@api.model
def default_get(self, default_fields):
res = super(AccountVoucherProformaDate, self).default_get(default_fields)
invoice_id = self.env.context.get("active_id")
invoice = self.env["account.move"].browse(invoice_id)
if invoice:
res["invoice_type"] = invoice.move_type
return res

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()
83 changes: 83 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,83 @@
<?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="invoice_type" invisible="1" />
<field
name="date"
string="Please enter invoice date"
attrs="{'invisible' : ['|',('invoice_type','=','in_invoice'),('invoice_type','=','in_refund')]}"
/>
<field
name="date"
string="Please enter bill date"
attrs="{'invisible' : ['|',('invoice_type','=','out_invoice'),('invoice_type','=','out_refund')]}"
/>

</group>
<footer>
<button
string='Confirm'
name="action_post"
default_focus="1"
type="object"
class="oe_highlight"
attrs="{'invisible' : ['|',('invoice_type','=','in_invoice'),('invoice_type','=','in_refund')]}"
/>
<button
string='Confirm'
name="action_post"
default_focus="1"
type="object"
class="oe_highlight"
attrs="{'invisible' : ['|',('invoice_type','=','out_invoice'),('invoice_type','=','out_refund')]}"
/>
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 402da0b

Please sign in to comment.