From 639178529aede40d73e58e5dd70bf400028ce2ed Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 21 May 2020 16:55:05 +0200 Subject: [PATCH 1/2] Re-introduce module agreement_account Update agreement and agreement_sale to restore the behavior of v10 [UPD] Update agreement_account.pot [UPD] README.rst --- agreement_account/README.rst | 84 ++++ agreement_account/__init__.py | 1 + agreement_account/__manifest__.py | 28 ++ agreement_account/i18n/agreement_account.pot | 58 +++ agreement_account/models/__init__.py | 2 + agreement_account/models/account_invoice.py | 15 + agreement_account/models/agreement.py | 36 ++ agreement_account/readme/CONTRIBUTORS.rst | 1 + agreement_account/readme/DESCRIPTION.rst | 1 + .../security/ir.model.access.csv | 3 + agreement_account/static/description/icon.png | Bin 0 -> 10512 bytes .../static/description/index.html | 421 ++++++++++++++++++ agreement_account/views/account_invoice.xml | 54 +++ agreement_account/views/agreement.xml | 61 +++ 14 files changed, 765 insertions(+) create mode 100644 agreement_account/README.rst create mode 100644 agreement_account/__init__.py create mode 100644 agreement_account/__manifest__.py create mode 100644 agreement_account/i18n/agreement_account.pot create mode 100644 agreement_account/models/__init__.py create mode 100644 agreement_account/models/account_invoice.py create mode 100644 agreement_account/models/agreement.py create mode 100644 agreement_account/readme/CONTRIBUTORS.rst create mode 100644 agreement_account/readme/DESCRIPTION.rst create mode 100644 agreement_account/security/ir.model.access.csv create mode 100644 agreement_account/static/description/icon.png create mode 100644 agreement_account/static/description/index.html create mode 100644 agreement_account/views/account_invoice.xml create mode 100644 agreement_account/views/agreement.xml diff --git a/agreement_account/README.rst b/agreement_account/README.rst new file mode 100644 index 000000000..bcfdcffdb --- /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/12.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/12.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..d70831428 --- /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': '12.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_invoice.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..720f31c8b --- /dev/null +++ b/agreement_account/models/__init__.py @@ -0,0 +1,2 @@ +from . import agreement +from . import account_invoice diff --git a/agreement_account/models/account_invoice.py b/agreement_account/models/account_invoice.py new file mode 100644 index 000000000..a6bdc4122 --- /dev/null +++ b/agreement_account/models/account_invoice.py @@ -0,0 +1,15 @@ +# 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 AccountInvoice(models.Model): + _inherit = 'account.invoice' + + agreement_id = fields.Many2one( + comodel_name='agreement', string='Agreement', ondelete='restrict', + track_visibility='onchange', 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..ddbc4ef42 --- /dev/null +++ b/agreement_account/models/agreement.py @@ -0,0 +1,36 @@ +# 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.invoice', '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), + ('state', 'not in', ('draft', 'cancel'))] + aio = self.env['account.invoice'] + out_rg_res = aio.read_group( + base_domain + [('type', 'in', ('out_invoice', 'out_refund'))], + ['agreement_id'], ['agreement_id']) + out_data = dict( + [(x['agreement_id'][0], x['agreement_id_count']) for x in out_rg_res]) + in_rg_res = aio.read_group( + base_domain + [('type', 'in', ('in_invoice', 'in_refund'))], + ['agreement_id'], ['agreement_id']) + in_data = dict( + [(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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-!0y0?IC^SESR|7U z^g;_E%a$B*e!b1=Vrb8>h~Q+>cz6@JUA&qTWnD`X-)}|2Cwam#2jW>+Evs|oe1TB5 zdB7YV0N5=c9p1##m#^K=;Ia#>MZkC3=|p%F5c9Q@+`A*dXis>mMAirtg9~7%wr;42 zFwn!x;35ZJ)33x4(V{|yQ@G>-uORZZq0O8`z0VR=8joUauKIxoR-`Alo{q?LcOV1 zI>+d8tgaE7kQ$dH6JhvElxG;Xiw~r75r1`Z*qw3ZDThOBR z<$^C`0VVw8Vw_2^%=rD}UPwn%i!6_fy!!jr*!)vl%i|bgorO#o{#U5U7$5QBu3G75 zhU|FPv%NxV+@cO^bv)1Db`sP(6v~Xxrd`#PH!(l9&ywusSTQpg6y5g5wjF2Eqbp#d zHj;#-nb~XhIMv4I#jaeHi3ZG+!Aa+5gdInxLmvOr;|x&B7aZaftY6jB@5tvnF5AoJ zL`#BL&$_!)hmVfjYJMAu)CdH23nsB+$hF0lf3tax@X~KWpjO{Cn zRcd4O10H^cS&Upo{}%Rc_U42bo9W}R4Q8WUhP{x;97;NNoRynlohiWXRKDxR;DpEA z%6=`2i>_h5jy0{W`TcWtw!xz0N|+2n9=s>F`atE1^3j?{l!1BYM>L6b3)#n#pkD?~ zawyLviEb?I8(C7xta&oiT%1>O(h@#7&KrHj@>~0LyD4dr=Hu_Cky75x5Ah!PoNXMz zU_VNYRdjupBky;Ia)sXomwXxhv^U{wYF}s&%KX(AWb`dB6FDGPc^iHFW$5)6yYM!f zxD4;#ljqxFZxYH|5^HM0z-+Ivw#iHJqBkS;fhT;Ly&z&PqNr+tsdqJ3dO< + + + + + +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/views/account_invoice.xml b/agreement_account/views/account_invoice.xml new file mode 100644 index 000000000..891ca4f05 --- /dev/null +++ b/agreement_account/views/account_invoice.xml @@ -0,0 +1,54 @@ + + + + + + + + agreement.customer.invoice.form + account.invoice + + + + + + + + + + + agreement.supplier.invoice.form + account.invoice + + + + + + + + + + agreement.account.invoice.search + account.invoice + + + + + + + + + + + + + diff --git a/agreement_account/views/agreement.xml b/agreement_account/views/agreement.xml new file mode 100644 index 000000000..36104570a --- /dev/null +++ b/agreement_account/views/agreement.xml @@ -0,0 +1,61 @@ + + + + + + + 150 + + + + + + Vendor Bills + account.invoice + tree,form + [('type','in', ('in_invoice', 'in_refund')), ('state', 'not in', ('draft', 'cancel'))] + {'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'} + + + + + tree + + + + + + + form + + + + + + invoice.button.agreement.form + agreement + + +
+ + + +
+
+
+ +
From 83e7c0ee9cf4f2c179668711e9dd814affdc4487 Mon Sep 17 00:00:00 2001 From: Patrick Wilson <36892066+patrickrwilson@users.noreply.github.com> Date: Tue, 18 May 2021 13:32:02 -0600 Subject: [PATCH 2/2] [14.0][MIG] agreement_account (Version 12.0 to 14.0) [MIG] Prettier and Black [MIG] Prettier [MIG] Fixed Tracking [ADD]Added the Tests. [IMP]Improved the Tests. --- agreement_account/README.rst | 6 +- agreement_account/__manifest__.py | 40 +++++----- agreement_account/models/__init__.py | 2 +- agreement_account/models/account_invoice.py | 15 ---- agreement_account/models/account_move.py | 20 +++++ agreement_account/models/agreement.py | 35 +++++---- agreement_account/tests/__init__.py | 1 + agreement_account/tests/test_agreement.py | 31 ++++++++ agreement_account/views/account_invoice.xml | 54 ------------- agreement_account/views/account_move.xml | 58 ++++++++++++++ agreement_account/views/agreement.xml | 87 +++++++++++++-------- 11 files changed, 209 insertions(+), 140 deletions(-) delete mode 100644 agreement_account/models/account_invoice.py create mode 100644 agreement_account/models/account_move.py create mode 100644 agreement_account/tests/__init__.py create mode 100644 agreement_account/tests/test_agreement.py delete mode 100644 agreement_account/views/account_invoice.xml create mode 100644 agreement_account/views/account_move.xml diff --git a/agreement_account/README.rst b/agreement_account/README.rst index bcfdcffdb..1aa005989 100644 --- a/agreement_account/README.rst +++ b/agreement_account/README.rst @@ -14,13 +14,13 @@ Agreement Account :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/12.0/agreement_account + :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/12.0 + :target: https://runbot.odoo-community.org/runbot/110/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -79,6 +79,6 @@ Current `maintainers `__: |maintainer-alexis-via| |maintainer-bealdav| -This module is part of the `OCA/contract `_ project on GitHub. +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/__manifest__.py b/agreement_account/__manifest__.py index d70831428..ba236f799 100644 --- a/agreement_account/__manifest__.py +++ b/agreement_account/__manifest__.py @@ -3,26 +3,26 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Agreement Account', - 'summary': "Agreement on invoices", - 'version': '12.0.1.0.0', - 'category': 'Contract', - 'author': 'Akretion, Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/contract', - 'license': 'AGPL-3', - 'depends': [ - 'agreement', - 'account', + "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_invoice.xml', - ], - 'development_status': 'Beta', - 'maintainers': [ - 'alexis-via', - 'bealdav', + "data": [ + "security/ir.model.access.csv", + "views/agreement.xml", + "views/account_move.xml", ], - 'installable': True, + "development_status": "Beta", + "maintainers": [ + "alexis-via", + "bealdav", + ], + "installable": True, } diff --git a/agreement_account/models/__init__.py b/agreement_account/models/__init__.py index 720f31c8b..77c035979 100644 --- a/agreement_account/models/__init__.py +++ b/agreement_account/models/__init__.py @@ -1,2 +1,2 @@ +from . import account_move from . import agreement -from . import account_invoice diff --git a/agreement_account/models/account_invoice.py b/agreement_account/models/account_invoice.py deleted file mode 100644 index a6bdc4122..000000000 --- a/agreement_account/models/account_invoice.py +++ /dev/null @@ -1,15 +0,0 @@ -# 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 AccountInvoice(models.Model): - _inherit = 'account.invoice' - - agreement_id = fields.Many2one( - comodel_name='agreement', string='Agreement', ondelete='restrict', - track_visibility='onchange', readonly=True, copy=False, - states={'draft': [('readonly', False)]}) 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 index ddbc4ef42..809228458 100644 --- a/agreement_account/models/agreement.py +++ b/agreement_account/models/agreement.py @@ -7,30 +7,33 @@ from odoo import fields, models class Agreement(models.Model): - _inherit = 'agreement' + _inherit = "agreement" invoice_ids = fields.One2many( - 'account.invoice', 'agreement_id', string='Invoices', readonly=True) + "account.move", "agreement_id", string="Invoices", readonly=True + ) out_invoice_count = fields.Integer( - compute='_compute_invoice_count', string='# of Customer Invoices') + compute="_compute_invoice_count", string="# of Customer Invoices" + ) in_invoice_count = fields.Integer( - compute='_compute_invoice_count', string='# of Vendor Bills') + compute="_compute_invoice_count", string="# of Vendor Bills" + ) def _compute_invoice_count(self): - base_domain = [ - ('agreement_id', 'in', self.ids), - ('state', 'not in', ('draft', 'cancel'))] - aio = self.env['account.invoice'] + base_domain = [("agreement_id", "in", self.ids)] + aio = self.env["account.move"] out_rg_res = aio.read_group( - base_domain + [('type', 'in', ('out_invoice', 'out_refund'))], - ['agreement_id'], ['agreement_id']) - out_data = dict( - [(x['agreement_id'][0], x['agreement_id_count']) for x in out_rg_res]) + 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 + [('type', 'in', ('in_invoice', 'in_refund'))], - ['agreement_id'], ['agreement_id']) - in_data = dict( - [(x['agreement_id'][0], x['agreement_id_count']) for x in in_rg_res]) + 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/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_invoice.xml b/agreement_account/views/account_invoice.xml deleted file mode 100644 index 891ca4f05..000000000 --- a/agreement_account/views/account_invoice.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - agreement.customer.invoice.form - account.invoice - - - - - - - - - - - agreement.supplier.invoice.form - account.invoice - - - - - - - - - - agreement.account.invoice.search - account.invoice - - - - - - - - - - - - - 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 index 36104570a..60db881bb 100644 --- a/agreement_account/views/agreement.xml +++ b/agreement_account/views/agreement.xml @@ -1,59 +1,84 @@ - - - + 150 - + Vendor Bills - account.invoice + account.move tree,form - [('type','in', ('in_invoice', 'in_refund')), ('state', 'not in', ('draft', 'cancel'))] - {'default_type': 'in_invoice', 'type': 'in_invoice', 'journal_type': 'purchase'} + [('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 - +
- - -