diff --git a/agreement_account/README.rst b/agreement_account/README.rst new file mode 100644 index 000000000..1aa005989 --- /dev/null +++ b/agreement_account/README.rst @@ -0,0 +1,84 @@ +================= +Agreement Account +================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fcontract-lightgray.png?logo=github + :target: https://github.com/OCA/contract/tree/14.0/agreement_account + :alt: OCA/contract +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-agreement_account + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/110/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds *Agreement* field on invoices. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Alexis de Lattre + +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-alexis-via| image:: https://github.com/alexis-via.png?size=40px + :target: https://github.com/alexis-via + :alt: alexis-via +.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px + :target: https://github.com/bealdav + :alt: bealdav + +Current `maintainers `__: + +|maintainer-alexis-via| |maintainer-bealdav| + +This module is part of the `OCA/contract `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/agreement_account/__init__.py b/agreement_account/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/agreement_account/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/agreement_account/__manifest__.py b/agreement_account/__manifest__.py new file mode 100644 index 000000000..ba236f799 --- /dev/null +++ b/agreement_account/__manifest__.py @@ -0,0 +1,28 @@ +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Agreement Account", + "summary": "Agreement on invoices", + "version": "14.0.1.0.0", + "category": "Contract", + "author": "Akretion, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/contract", + "license": "AGPL-3", + "depends": [ + "agreement", + "account", + ], + "data": [ + "security/ir.model.access.csv", + "views/agreement.xml", + "views/account_move.xml", + ], + "development_status": "Beta", + "maintainers": [ + "alexis-via", + "bealdav", + ], + "installable": True, +} diff --git a/agreement_account/i18n/agreement_account.pot b/agreement_account/i18n/agreement_account.pot new file mode 100644 index 000000000..adbea5969 --- /dev/null +++ b/agreement_account/i18n/agreement_account.pot @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * agreement_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: agreement_account +#: model:ir.model.fields,field_description:agreement_account.field_agreement__out_invoice_count +msgid "# of Customer Invoices" +msgstr "" + +#. module: agreement_account +#: model:ir.model.fields,field_description:agreement_account.field_agreement__in_invoice_count +msgid "# of Vendor Bills" +msgstr "" + +#. module: agreement_account +#: model:ir.model,name:agreement_account.model_agreement +#: model:ir.model.fields,field_description:agreement_account.field_account_invoice__agreement_id +#: model_terms:ir.ui.view,arch_db:agreement_account.view_account_invoice_filter +msgid "Agreement" +msgstr "" + +#. module: agreement_account +#: model:ir.ui.menu,name:agreement_account.agreement_type_menu +msgid "Agreement Types" +msgstr "" + +#. module: agreement_account +#: model_terms:ir.ui.view,arch_db:agreement_account.agreement_form +msgid "Customer Invoices" +msgstr "" + +#. module: agreement_account +#: model:ir.model,name:agreement_account.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: agreement_account +#: model:ir.model.fields,field_description:agreement_account.field_agreement__invoice_ids +msgid "Invoices" +msgstr "" + +#. module: agreement_account +#: model:ir.actions.act_window,name:agreement_account.account_invoice_in_invoice_refund_action +#: model_terms:ir.ui.view,arch_db:agreement_account.agreement_form +msgid "Vendor Bills" +msgstr "" + diff --git a/agreement_account/models/__init__.py b/agreement_account/models/__init__.py new file mode 100644 index 000000000..77c035979 --- /dev/null +++ b/agreement_account/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move +from . import agreement diff --git a/agreement_account/models/account_move.py b/agreement_account/models/account_move.py new file mode 100644 index 000000000..e8e0d798d --- /dev/null +++ b/agreement_account/models/account_move.py @@ -0,0 +1,20 @@ +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + agreement_id = fields.Many2one( + comodel_name="agreement", + string="Agreement", + ondelete="restrict", + tracking=True, + readonly=True, + copy=False, + states={"draft": [("readonly", False)]}, + ) diff --git a/agreement_account/models/agreement.py b/agreement_account/models/agreement.py new file mode 100644 index 000000000..809228458 --- /dev/null +++ b/agreement_account/models/agreement.py @@ -0,0 +1,39 @@ +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class Agreement(models.Model): + _inherit = "agreement" + + invoice_ids = fields.One2many( + "account.move", "agreement_id", string="Invoices", readonly=True + ) + out_invoice_count = fields.Integer( + compute="_compute_invoice_count", string="# of Customer Invoices" + ) + in_invoice_count = fields.Integer( + compute="_compute_invoice_count", string="# of Vendor Bills" + ) + + def _compute_invoice_count(self): + base_domain = [("agreement_id", "in", self.ids)] + aio = self.env["account.move"] + out_rg_res = aio.read_group( + base_domain + [("move_type", "in", ("out_invoice", "out_refund"))], + ["agreement_id"], + ["agreement_id"], + ) + out_data = {x["agreement_id"][0]: x["agreement_id_count"] for x in out_rg_res} + in_rg_res = aio.read_group( + base_domain + [("move_type", "in", ("in_invoice", "in_refund"))], + ["agreement_id"], + ["agreement_id"], + ) + in_data = {x["agreement_id"][0]: x["agreement_id_count"] for x in in_rg_res} + for agreement in self: + agreement.out_invoice_count = out_data.get(agreement.id, 0) + agreement.in_invoice_count = in_data.get(agreement.id, 0) diff --git a/agreement_account/readme/CONTRIBUTORS.rst b/agreement_account/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..ff65d68ce --- /dev/null +++ b/agreement_account/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexis de Lattre diff --git a/agreement_account/readme/DESCRIPTION.rst b/agreement_account/readme/DESCRIPTION.rst new file mode 100644 index 000000000..18e63adc3 --- /dev/null +++ b/agreement_account/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds *Agreement* field on invoices. diff --git a/agreement_account/security/ir.model.access.csv b/agreement_account/security/ir.model.access.csv new file mode 100644 index 000000000..c1b7f487c --- /dev/null +++ b/agreement_account/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_agreement_full,Full access on agreement to Financial mgr,agreement.model_agreement,account.group_account_manager,1,1,1,1 +access_agreement_type_full,Full access on agreement type to Financial mgr,agreement.model_agreement_type,account.group_account_manager,1,1,1,1 diff --git a/agreement_account/static/description/icon.png b/agreement_account/static/description/icon.png new file mode 100644 index 000000000..a99cce6be Binary files /dev/null and b/agreement_account/static/description/icon.png differ diff --git a/agreement_account/static/description/index.html b/agreement_account/static/description/index.html new file mode 100644 index 000000000..c0e8085e6 --- /dev/null +++ b/agreement_account/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Agreement Account + + + +
+

Agreement Account

+ + +

Beta License: AGPL-3 OCA/contract Translate me on Weblate Try me on Runbot

+

This module adds Agreement field on invoices.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainers:

+

alexis-via bealdav

+

This module is part of the OCA/contract project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/agreement_account/tests/__init__.py b/agreement_account/tests/__init__.py new file mode 100644 index 000000000..b636caa99 --- /dev/null +++ b/agreement_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_agreement diff --git a/agreement_account/tests/test_agreement.py b/agreement_account/tests/test_agreement.py new file mode 100644 index 000000000..9a2982da9 --- /dev/null +++ b/agreement_account/tests/test_agreement.py @@ -0,0 +1,31 @@ +# Copyright 2017-2020 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestAgreement(TransactionCase): + def setUp(self): + super().setUp() + self.test_customer = self.env["res.partner"].create({"name": "TestCustomer"}) + self.test_agreement_sale = self.env["agreement"].create( + { + "name": "TestAgreement-Sale", + "code": "SALE", + "partner_id": self.test_customer.id, + "domain": "sale", + } + ) + self.test_agreement_purchase = self.env["agreement"].create( + { + "name": "TestAgreement-Purchase", + "code": "PURCHASE", + "partner_id": self.test_customer.id, + "domain": "purchase", + } + ) + + def test_compute_invoice_count(self): + self.test_agreement_sale._compute_invoice_count() + self.test_agreement_purchase._compute_invoice_count() diff --git a/agreement_account/views/account_move.xml b/agreement_account/views/account_move.xml new file mode 100644 index 000000000..459270743 --- /dev/null +++ b/agreement_account/views/account_move.xml @@ -0,0 +1,58 @@ + + + + + agreement.customer.invoice.form + account.move + + + + + + + + + + + agreement.supplier.invoice.form + account.move + + + + + + + + + + agreement.account.move.search + account.move + + + + + + + + + + + + diff --git a/agreement_account/views/agreement.xml b/agreement_account/views/agreement.xml new file mode 100644 index 000000000..60db881bb --- /dev/null +++ b/agreement_account/views/agreement.xml @@ -0,0 +1,86 @@ + + + + + 150 + + + + + + Vendor Bills + account.move + tree,form + [('move_type','in', ('in_invoice', 'in_refund')), ('state', 'not in', ('draft', 'cancel'))] + {'default_type': 'in_invoice', 'move_type': 'in_invoice', 'journal_type': 'purchase'} + + + + + tree + + + + + + + form + + + + + + invoice.button.agreement.form + agreement + + +
+ + +
+
+
+ +