Skip to content

Commit

Permalink
[MIG] purchase_request_analytic: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Juany Davila authored and JasminSForgeFlow committed Jul 25, 2023
1 parent db12c28 commit 0566d42
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 45 deletions.
12 changes: 6 additions & 6 deletions purchase_request_analytic/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -67,7 +67,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/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-analytic/issues/new?body=module:%20purchase_request_analytic%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20purchase_request_analytic%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.

Expand All @@ -82,7 +82,7 @@ Authors
Contributors
~~~~~~~~~~~~

* Beñat Jimenez <benat.jimenez@eficent.com>
* Beñat Jimenez <benat.jimenez@forgeflow.com>
* Pimolnat Suntian <[email protected]>
* Juany Davila <[email protected]>

Expand All @@ -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 <https://github.com/OCA/account-analytic/tree/14.0/purchase_request_analytic>`_ project on GitHub.
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/15.0/purchase_request_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions purchase_request_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
31 changes: 3 additions & 28 deletions purchase_request_analytic/models/purchase_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion purchase_request_analytic/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* Beñat Jimenez <benat.jimenez@eficent.com>
* Beñat Jimenez <benat.jimenez@forgeflow.com>
* Pimolnat Suntian <[email protected]>
* Juany Davila <[email protected]>
10 changes: 5 additions & 5 deletions purchase_request_analytic/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Purchase Request Analytic</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Purchase Request Analytic</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-analytic/tree/14.0/purchase_request_analytic"><img alt="OCA/account-analytic" src="https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-analytic-14-0/account-analytic-14-0-purchase_request_analytic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/87/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-analytic/tree/15.0/purchase_request_analytic"><img alt="OCA/account-analytic" src="https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-analytic-15-0/account-analytic-15-0-purchase_request_analytic"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/87/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds the analytic account field to Purchase Requests.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -420,7 +420,7 @@ <h1><a class="toc-backref" href="#id11">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-analytic/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-analytic/issues/new?body=module:%20purchase_request_analytic%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-analytic/issues/new?body=module:%20purchase_request_analytic%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -434,7 +434,7 @@ <h2><a class="toc-backref" href="#id13">Authors</a></h2>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id14">Contributors</a></h2>
<ul class="simple">
<li>Beñat Jimenez &lt;<a class="reference external" href="mailto:benat.jimenez&#64;eficent.com">benat.jimenez&#64;eficent.com</a>&gt;</li>
<li>Beñat Jimenez &lt;<a class="reference external" href="mailto:benat.jimenez&#64;forgeflow.com">benat.jimenez&#64;forgeflow.com</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
<li>Juany Davila &lt;<a class="reference external" href="mailto:juany.davila&#64;forgeflow.com">juany.davila&#64;forgeflow.com</a>&gt;</li>
</ul>
Expand All @@ -446,7 +446,7 @@ <h2><a class="toc-backref" href="#id15">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-analytic/tree/14.0/purchase_request_analytic">OCA/account-analytic</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-analytic/tree/15.0/purchase_request_analytic">OCA/account-analytic</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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).

from odoo.tests.common import TransactionCase
Expand Down Expand Up @@ -47,5 +47,4 @@ def test_analytic(self):
pr = self.env["purchase.request"].new(
{"requested_by": self.env.user.id, "analytic_account_id": self.anal_id.id}
)
pr._onchange_analytic_account_id()
self.assertEqual(pr.analytic_account_id.id, self.anal_id.id)
1 change: 0 additions & 1 deletion purchase_request_analytic/views/purchase_request_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<field name="arch" type="xml">
<data>
<field name="date_start" position="after">
<field name="analytic_account_id2" invisible="1" />
<field
name="analytic_account_id"
groups="analytic.group_analytic_accounting"
Expand Down

0 comments on commit 0566d42

Please sign in to comment.