Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] purchase_request_analytic: Migration to 17.0 #671

Open
wants to merge 22 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7567d59
[10.0][ADD] purchase_request_analytic: Add analytic account to Purcha…
bjeficent Apr 29, 2019
190fd68
[FIX]do not restrict picking type for analytic.
AaronHForgeFlow May 9, 2019
bf32ee7
[UPD] Update purchase_request_analytic.pot
oca-travis Oct 29, 2019
2d05f29
[ADD] icon.png
OCA-git-bot Oct 29, 2019
ec9c10a
[MIG] purchase_request_analytic: Migration to 12.0
MiquelRForgeFlow Oct 29, 2019
478e1d6
[UPD] Update purchase_request_analytic.pot
oca-travis Nov 5, 2019
ac8493d
[UPD] README.rst
OCA-git-bot Nov 5, 2019
4449def
[IMP] purchase_request_analytic: black, isort
ps-tubtim Jan 8, 2020
ca45a5d
[MIG] purchase_request_analytic: Migration to 13.0
ps-tubtim Mar 24, 2020
d446534
[UPD] Update purchase_request_analytic.pot
oca-travis Dec 2, 2021
6911bb9
[IMP] purchase_request_analytic: black, isort, prettier
May 18, 2022
8b971fc
[MIG] purchase_request_analytic: Migration to 14.0
May 18, 2022
1c64622
[UPD] Update purchase_request_analytic.pot
May 20, 2022
af03424
[UPD] README.rst
OCA-git-bot May 20, 2022
9ff544b
[MIG] purchase_request_analytic: Migration to 15.0
Jun 21, 2022
e77300d
[UPD] Update purchase_request_analytic.pot
Jul 26, 2023
05d7df2
[UPD] README.rst
OCA-git-bot Jul 26, 2023
32224f8
[UPD] README.rst
OCA-git-bot Sep 3, 2023
781cc34
[FIX] purchase_request_analytic: fill analytic account id in the purc…
AaronHForgeFlow Mar 19, 2024
636e5bd
[BOT] post-merge updates
OCA-git-bot Jul 4, 2024
1829c07
[IMP] purchase_request_analytic: pre-commit auto fixes
StefanRijnhart Jul 4, 2024
e67cda7
[MIG] purchase_request_analytic: Migration to 17.0
StefanRijnhart Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions purchase_request_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
=========================
Purchase Request Analytic
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e5d542b4f36801b7d89139c82816d3daaeff1caff8abf8e095ff1f74f576d5d3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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--analytic-lightgray.png?logo=github
:target: https://github.com/OCA/account-analytic/tree/17.-/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-17--/account-analytic-17---purchase_request_analytic
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=17.-
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds an analytic distribution field to Purchase Requests.
The field serves as a default for new lines on a request.

**Table of contents**

.. contents::
:local:

Usage
=====

- Assign an analytic distribution to the purchase request or to
purchase request lines.

Changelog
=========

13.0.1.0.0 (2020-01-08)
-----------------------

Migrated to odoo 13.

12.0.1.0.0 (2019-10-30)
-----------------------

Migrated to odoo 12.

10.0.1.0.1 (2019-05-09)
-----------------------

[FIX] Do not restrict picking type for analytic. [IMP] Add tests.

10.0.1.0.0 (2019-04-29)
-----------------------

First version.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20purchase_request_analytic%0Aversion:%2017.-%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
-------

* ForgeFlow

Contributors
------------

- Beñat Jimenez <[email protected]>
- Pimolnat Suntian <[email protected]>
- Juany Davila <[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-analytic <https://github.com/OCA/account-analytic/tree/17.-/purchase_request_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions purchase_request_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions purchase_request_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Purchase Request Analytic",
"version": "17.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"category": "Purchase Management",
"website": "https://github.com/OCA/account-analytic",
"depends": ["purchase_request"],
"data": ["views/purchase_request_views.xml"],
"license": "AGPL-3",
"installable": True,
}
30 changes: 30 additions & 0 deletions purchase_request_analytic/i18n/purchase_request_analytic.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_request_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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: purchase_request_analytic
#: model:ir.model.fields,field_description:purchase_request_analytic.field_purchase_request__analytic_account_id
#: model_terms:ir.ui.view,arch_db:purchase_request_analytic.view_purchase_request_search
msgid "Analytic Account"
msgstr ""

#. module: purchase_request_analytic
#: model:ir.model,name:purchase_request_analytic.model_purchase_request
msgid "Purchase Request"
msgstr ""

#. module: purchase_request_analytic
#: model:ir.model.fields,help:purchase_request_analytic.field_purchase_request__analytic_account_id
msgid "The analytic account related to a sales order."
msgstr ""
15 changes: 15 additions & 0 deletions purchase_request_analytic/migrations/16.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo.tools.sql import column_exists


def migrate(cr, version):
"""Populate analytic distribution values from the old analytic account"""
if column_exists(cr, "purchase_request", "analytic_distribution"):
return
cr.execute(
"""
ALTER TABLE purchase_request ADD COLUMN analytic_distribution jsonb;
update purchase_request set analytic_distribution =
json_build_object(analytic_account_id::varchar, 100.0)
where analytic_account_id is not null;
"""
)
1 change: 1 addition & 0 deletions purchase_request_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase_request
41 changes: 41 additions & 0 deletions purchase_request_analytic/models/purchase_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2019 ForgeFlow S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class PurchaseRequest(models.Model):
_name = "purchase.request"
_inherit = ["analytic.mixin", "purchase.request"]

analytic_distribution = fields.Json(
inverse="_inverse_analytic_distribution",
help="The default distribution for new lines on this request",
)

@api.depends("line_ids.analytic_distribution")
def _compute_analytic_distribution(self):
"""Take the distribution that is already set on all of our lines."""
for pr in self:
al = pr.analytic_distribution
if pr.line_ids:
first_line_analytic_distribution = pr.line_ids[0].analytic_distribution
all_lines_same = all(
prl.analytic_distribution == first_line_analytic_distribution
for prl in pr.line_ids
)
# If all lines share the same analytic_distribution,
# set it to the purchase request.
if all_lines_same:
pr.analytic_distribution = first_line_analytic_distribution
continue
for prl in pr.line_ids:
if prl.analytic_distribution != al:
al = False
break
pr.analytic_distribution = al

def _inverse_analytic_distribution(self):
"""Set this requests's distribution on all of its lines."""
for pr in self.filtered("analytic_distribution"):
pr.line_ids.analytic_distribution = pr.analytic_distribution
3 changes: 3 additions & 0 deletions purchase_request_analytic/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions purchase_request_analytic/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Beñat Jimenez \<<[email protected]>\>
- Pimolnat Suntian \<<[email protected]>\>
- Juany Davila \<<[email protected]>\>
2 changes: 2 additions & 0 deletions purchase_request_analytic/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module adds an analytic distribution field to Purchase Requests. The field
serves as a default for new lines on a request.
15 changes: 15 additions & 0 deletions purchase_request_analytic/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## 13.0.1.0.0 (2020-01-08)

Migrated to odoo 13.

## 12.0.1.0.0 (2019-10-30)

Migrated to odoo 12.

## 10.0.1.0.1 (2019-05-09)

\[FIX\] Do not restrict picking type for analytic. \[IMP\] Add tests.

## 10.0.1.0.0 (2019-04-29)

First version.
3 changes: 3 additions & 0 deletions purchase_request_analytic/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Assign an analytic distribution to the purchase request or to purchase
request lines.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading