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

[MIG][16.0] product_analytic_purchase #576

Merged
merged 20 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
66d1cd9
product_analytic: add method _get_product_analytic_accounts() similar…
alexis-via Jul 17, 2017
3aa0e55
OCA Transbot updated translations from Transifex
oca-transbot Feb 23, 2018
d380dd1
OCA Transbot updated translations from Transifex
oca-transbot Mar 2, 2018
e81ed83
[UPD] Update product_analytic_purchase.pot
oca-travis Jun 29, 2018
3c5abef
Added translation using Weblate (Catalan)
Oct 10, 2018
e87a02c
Translated using Weblate (Catalan)
Oct 12, 2018
bb4bf8d
[ADD] icon.png
OCA-git-bot Apr 3, 2019
adf1290
[10.0][IMP] product_analytic_purchase: black, isort, prettier
Reyes4711-S73 May 14, 2021
37a1271
[14.0][MIG] product_analytic_purchase: Migration to 14.0
Reyes4711-S73 Oct 25, 2021
9ec5560
[UPD] Update product_analytic_purchase.pot
May 17, 2022
3771702
product_analytic_purchase 14.0.1.0.1
OCA-git-bot May 17, 2022
cf397d1
Added translation using Weblate (Italian)
francesco-ooops Nov 14, 2022
ffbfd4c
Translated using Weblate (Italian)
francesco-ooops Nov 14, 2022
139febc
[MIG][15.0]product_analytic_purchase:Migration to 15.0
bizzappdev Mar 7, 2023
4ce8d1f
[IMP] product_analytic_purchase: pre-commit stuff
rousseldenis Jul 19, 2023
19ab54f
[MIG][16.0] product_analytic_purchase
rousseldenis Jul 19, 2023
401dcc7
[IMP] product_analytic_purchase: Improve tests
rousseldenis Jul 19, 2023
7570d8f
[IMP] product_analytic_purchase: Add readme fragments
rousseldenis Jul 19, 2023
d2745f8
[IMP] Add stock modules to rebel group
rousseldenis Jul 19, 2023
d9babfd
[FIX] product_analytic_purchase: Check if analytic account is filled in
rousseldenis Nov 16, 2023
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
3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ odoo_test_flavor: Both
odoo_version: 16.0
org_name: Odoo Community Association (OCA)
org_slug: OCA
rebel_module_groups: []
rebel_module_groups:
- purchase_stock_analytic, stock_analytic
repo_description: 'TODO: add repo description.'
repo_name: account-analytic
repo_slug: account-analytic
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ jobs:
matrix:
include:
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
include: "purchase_stock_analytic, stock_analytic"
makepot: "true"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
include: "purchase_stock_analytic, stock_analytic"
name: test with OCB
- container: ghcr.io/oca/oca-ci/py3.10-odoo16.0:latest
exclude: "purchase_stock_analytic, stock_analytic"
makepot: "true"
name: test with Odoo
- container: ghcr.io/oca/oca-ci/py3.10-ocb16.0:latest
exclude: "purchase_stock_analytic, stock_analytic"
name: test with OCB
makepot: "true"
services:
Expand All @@ -49,6 +59,9 @@ jobs:
POSTGRES_DB: odoo
ports:
- 5432:5432
env:
INCLUDE: "${{ matrix.include }}"
EXCLUDE: "${{ matrix.exclude }}"
steps:
- uses: actions/checkout@v3
with:
Expand Down
87 changes: 87 additions & 0 deletions product_analytic_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
=========================
Product Analytic Purchase
=========================

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

.. |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/16.0/product_analytic_purchase
: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-16-0/account-analytic-16-0-product_analytic_purchase
: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=16.0
:alt: Try me on Runboat

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

This module is a glue module between the *product_analytic* and
*purchase* modules.

**Table of contents**

.. contents::
:local:

Usage
=====

When you create a purchase order line with a product that has an
**expense analytic account** (or whose internal category has an
**expense analytic account**), it will be automatically set on the
purchase order line.

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:%20product_analytic_purchase%0Aversion:%2016.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.

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Alexis de Lattre <alexis.delattre@akretion.com>
* Carlos Reyes <carlos@studio73.es>
* Denis Roussel <denis.roussel@acsone.eu>

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/16.0/product_analytic_purchase>`_ 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 product_analytic_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions product_analytic_purchase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2017 Akretion (http://www.akretion.com/) - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Product Analytic Purchase",
"version": "16.0.1.0.0",
"category": "Purchases",
"license": "AGPL-3",
"summary": "Glue module between purchase and product_analytic",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": ["purchase", "product_analytic"],
"auto_install": True,
"installable": True,
}
22 changes: 22 additions & 0 deletions product_analytic_purchase/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2018-10-12 20:00+0000\n"
"Last-Translator: Harald Panten <harald.panten@qubiq.es>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.1.1\n"

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Línia de comanda de compra"
25 changes: 25 additions & 0 deletions product_analytic_purchase/i18n/cs_CZ.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
# Translators:
# Lukáš Spurný <lukasspurny8@gmail.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-21 03:54+0000\n"
"PO-Revision-Date: 2018-02-21 03:54+0000\n"
"Last-Translator: Lukáš Spurný <lukasspurny8@gmail.com>, 2018\n"
"Language-Team: Czech (Czech Republic) (https://www.transifex.com/oca/"
"teams/23907/cs_CZ/)\n"
"Language: cs_CZ\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Řádek objednávky"
24 changes: 24 additions & 0 deletions product_analytic_purchase/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
# Translators:
# enjolras <yo@miguelrevilla.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-21 03:54+0000\n"
"PO-Revision-Date: 2018-02-21 03:54+0000\n"
"Last-Translator: enjolras <yo@miguelrevilla.com>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Línea de pedido de compra"
24 changes: 24 additions & 0 deletions product_analytic_purchase/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
# Translators:
# Quentin THEURET <odoo@kerpeo.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-23 23:11+0000\n"
"PO-Revision-Date: 2018-02-23 23:11+0000\n"
"Last-Translator: Quentin THEURET <odoo@kerpeo.com>, 2018\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Ligne de commande"
25 changes: 25 additions & 0 deletions product_analytic_purchase/i18n/hr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
# Translators:
# Bole <bole@dajmi5.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-02-21 03:54+0000\n"
"PO-Revision-Date: 2018-02-21 03:54+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>, 2018\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Stavka naloga za nabavu"
37 changes: 37 additions & 0 deletions product_analytic_purchase/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-11-14 16:09+0000\n"
"Last-Translator: Francesco Foresti <francesco.foresti@ooops404.com>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"

#. module: product_analytic_purchase
#: model:ir.model.fields,field_description:product_analytic_purchase.field_purchase_order_line__display_name
msgid "Display Name"
msgstr "Nome visualizzato"

#. module: product_analytic_purchase
#: model:ir.model.fields,field_description:product_analytic_purchase.field_purchase_order_line__id
msgid "ID"
msgstr "ID"

#. module: product_analytic_purchase
#: model:ir.model.fields,field_description:product_analytic_purchase.field_purchase_order_line____last_update
msgid "Last Modified on"
msgstr "Ultima modifica il"

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Riga ordine di acquisto"
34 changes: 34 additions & 0 deletions product_analytic_purchase/i18n/product_analytic_purchase.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_analytic_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.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: product_analytic_purchase
#: model:ir.model.fields,field_description:product_analytic_purchase.field_purchase_order_line__display_name
msgid "Display Name"
msgstr ""

#. module: product_analytic_purchase
#: model:ir.model.fields,field_description:product_analytic_purchase.field_purchase_order_line__id
msgid "ID"
msgstr ""

#. module: product_analytic_purchase
#: model:ir.model.fields,field_description:product_analytic_purchase.field_purchase_order_line____last_update
msgid "Last Modified on"
msgstr ""

#. module: product_analytic_purchase
#: model:ir.model,name:product_analytic_purchase.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""
1 change: 1 addition & 0 deletions product_analytic_purchase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import purchase_order_line
40 changes: 40 additions & 0 deletions product_analytic_purchase/models/purchase_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2017 Akretion (http://www.akretion.com/) - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

def _compute_analytic_distribution(self):
"""
Get analytic distribution from product expense analytic account
If no account is set, call super with those records
"""
lines_without_analytic_ids = set()
for line in self:
if line.product_id:
ana_accounts = (
line.product_id.product_tmpl_id._get_product_analytic_accounts()
)
ana_account = ana_accounts["expense"]
if ana_account:
line.analytic_distribution = {ana_account.id: 100}
else:
lines_without_analytic_ids.add(line.id)
return super(
PurchaseOrderLine, self.browse(lines_without_analytic_ids)
)._compute_analytic_distribution()

@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get("product_id") and not vals.get("analytic_distribution"):
product = self.env["product.product"].browse(vals.get("product_id"))
ana_accounts = product.product_tmpl_id._get_product_analytic_accounts()
ana_account = ana_accounts["expense"]
vals["analytic_distribution"] = (
{ana_account.id: 100.0} if ana_account else False
)
return super().create(vals_list)
3 changes: 3 additions & 0 deletions product_analytic_purchase/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Alexis de Lattre <alexis.delattre@akretion.com>
* Carlos Reyes <carlos@studio73.es>
* Denis Roussel <denis.roussel@acsone.eu>
2 changes: 2 additions & 0 deletions product_analytic_purchase/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module is a glue module between the *product_analytic* and
*purchase* modules.
4 changes: 4 additions & 0 deletions product_analytic_purchase/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
When you create a purchase order line with a product that has an
**expense analytic account** (or whose internal category has an
**expense analytic account**), it will be automatically set on the
purchase order line.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading