From 0566d42c84ff9232bd346046d96cbb928f221529 Mon Sep 17 00:00:00 2001 From: Juany Davila Date: Tue, 21 Jun 2022 14:25:33 -0500 Subject: [PATCH] [MIG] purchase_request_analytic: Migration to 15.0 --- purchase_request_analytic/README.rst | 12 +++---- purchase_request_analytic/__manifest__.py | 4 +-- .../models/purchase_request.py | 31 ++----------------- .../readme/CONTRIBUTORS.rst | 2 +- .../static/description/index.html | 10 +++--- .../tests/test_purchase_request_analytic.py | 3 +- .../views/purchase_request_views.xml | 1 - 7 files changed, 18 insertions(+), 45 deletions(-) diff --git a/purchase_request_analytic/README.rst b/purchase_request_analytic/README.rst index 4420eb14ef..aad315c6af 100644 --- a/purchase_request_analytic/README.rst +++ b/purchase_request_analytic/README.rst @@ -14,13 +14,13 @@ Purchase Request Analytic :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--analytic-lightgray.png?logo=github - :target: https://github.com/OCA/account-analytic/tree/14.0/purchase_request_analytic + :target: https://github.com/OCA/account-analytic/tree/15.0/purchase_request_analytic :alt: OCA/account-analytic .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/account-analytic-14-0/account-analytic-14-0-purchase_request_analytic + :target: https://translation.odoo-community.org/projects/account-analytic-15-0/account-analytic-15-0-purchase_request_analytic :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/87/14.0 + :target: https://runbot.odoo-community.org/runbot/87/15.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -67,7 +67,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -82,7 +82,7 @@ Authors Contributors ~~~~~~~~~~~~ -* Beñat Jimenez +* Beñat Jimenez * Pimolnat Suntian * Juany Davila @@ -99,6 +99,6 @@ 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-analytic `_ project on GitHub. +This module is part of the `OCA/account-analytic `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_request_analytic/__manifest__.py b/purchase_request_analytic/__manifest__.py index 4c38eb3678..5b2fff35a9 100644 --- a/purchase_request_analytic/__manifest__.py +++ b/purchase_request_analytic/__manifest__.py @@ -1,9 +1,9 @@ -# Copyright 2019 Eficent Business and IT Consulting Services S.L. +# Copyright 2019 ForgeFlow S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Purchase Request Analytic", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "author": "ForgeFlow, Odoo Community Association (OCA)", "category": "Purchase Management", "website": "https://github.com/OCA/account-analytic", diff --git a/purchase_request_analytic/models/purchase_request.py b/purchase_request_analytic/models/purchase_request.py index 80ee1fa701..494f619cb7 100644 --- a/purchase_request_analytic/models/purchase_request.py +++ b/purchase_request_analytic/models/purchase_request.py @@ -7,10 +7,6 @@ class PurchaseRequest(models.Model): _inherit = "purchase.request" - analytic_account_id2 = fields.Many2one( - comodel_name="account.analytic.account", - help="Use to store the value of analytic_account if there is no lines", - ) analytic_account_id = fields.Many2one( compute="_compute_analytic_account_id", inverse="_inverse_analytic_account_id", @@ -28,9 +24,8 @@ def _compute_analytic_account_id(self): analytic_account_id """ for pr in self: - al = pr.analytic_account_id2 + al = pr.analytic_account_id if pr.line_ids: - al = pr.line_ids[0].analytic_account_id or False for prl in pr.line_ids: if prl.analytic_account_id != al: al = False @@ -43,25 +38,5 @@ def _inverse_analytic_account_id(self): """ for pr in self: if pr.analytic_account_id: - pr.line_ids.write({"analytic_account_id": pr.analytic_account_id.id}) - pr.analytic_account_id2 = pr.analytic_account_id - - @api.onchange("analytic_account_id") - def _onchange_analytic_account_id(self): - """When analytic_account_id is changed, set analytic account on all - purchase request lines. - Do it in one operation to avoid to recompute the - analytic_account_id field during the change. - In case of new record, nothing is recomputed to avoid ugly message - """ - res = [] - for prl in self.line_ids: - if isinstance(prl.id, int): - res.append( - (1, prl.id, {"analytic_account_id": self.analytic_account_id.id}) - ) - else: - # this is new record, do nothing ! - return - self.analytic_account_id2 = self.analytic_account_id - self.line_ids = res + for line in pr.line_ids: + line.analytic_account_id = pr.analytic_account_id.id diff --git a/purchase_request_analytic/readme/CONTRIBUTORS.rst b/purchase_request_analytic/readme/CONTRIBUTORS.rst index d9c4556f74..a7df2a8929 100644 --- a/purchase_request_analytic/readme/CONTRIBUTORS.rst +++ b/purchase_request_analytic/readme/CONTRIBUTORS.rst @@ -1,3 +1,3 @@ -* Beñat Jimenez +* Beñat Jimenez * Pimolnat Suntian * Juany Davila diff --git a/purchase_request_analytic/static/description/index.html b/purchase_request_analytic/static/description/index.html index 68e27152d7..1ffd72048c 100644 --- a/purchase_request_analytic/static/description/index.html +++ b/purchase_request_analytic/static/description/index.html @@ -3,7 +3,7 @@ - + Purchase Request Analytic