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] procurement_mto_analytic: Migration to 17.0 #735

Open
wants to merge 24 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
24 commits
Select commit Hold shift + click to select a range
027df6a
[MIG] purchase_procurement_analytic > procurement_mto_analytic: Migra…
Nov 14, 2018
556d6f0
[UPD] README.rst
OCA-git-bot Nov 20, 2018
5cb00d7
[UPD] Update procurement_mto_analytic.pot
oca-travis Nov 20, 2018
ed41abd
[MIG] procurement_mto_analytic: Migration to 12.0
Feb 18, 2019
70427d2
[ADD] Add feature to set analytic account for purchase lines of servi…
Feb 19, 2019
983b82b
[UPD] README.rst
OCA-git-bot Feb 25, 2019
94437b5
[UPD] Update procurement_mto_analytic.pot
oca-travis Feb 25, 2019
bb221ab
[UPD] README.rst
OCA-git-bot Jul 29, 2019
b1e79de
[IMP] procurement_mto_analytic: black, isort
ps-tubtim Jan 8, 2020
9187494
[MIG] procurement_mto_analytic: Migration to 13.0
ps-tubtim Mar 24, 2020
2ac1e0e
[UPD] Update procurement_mto_analytic.pot
oca-travis Mar 24, 2020
3465bb1
Added translation using Weblate (Spanish)
eduardgm Mar 26, 2021
118ee34
Added translation using Weblate (Catalan)
eduardgm Mar 26, 2021
9260327
Translated using Weblate (Spanish)
eduardgm Mar 26, 2021
f953236
Translated using Weblate (Catalan)
eduardgm Mar 26, 2021
557986a
[IMP] procurement_mto_analytic: black, isort, prettier
alan196 Nov 29, 2021
782fe05
[MIG] : Migration to 15.0
alan196 Nov 29, 2021
d24308a
[UPD] Update procurement_mto_analytic.pot
Feb 7, 2022
9eb22c6
[UPD] README.rst
OCA-git-bot Feb 7, 2022
c923382
Update translation files
weblate Oct 9, 2023
cc0b195
Translated using Weblate (Spanish)
Ivorra78 Oct 23, 2023
b5c5c65
Translated using Weblate (Catalan)
jaumeplanas Sep 11, 2024
0da7a59
[IMP] procurement_mto_analytic: pre-commit auto fixes
alan196 Jan 17, 2025
5bab53f
[MIG] procurement_mto_analytic: Migration to 17.0
alan196 Jan 18, 2025
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
133 changes: 133 additions & 0 deletions procurement_mto_analytic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
=======================
Purchase Analytic (MTO)
=======================

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

.. |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.0/procurement_mto_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-0/account-analytic-17-0-procurement_mto_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.0
:alt: Try me on Runboat

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

This module takes analytic distribution value from sale order to the
created purchase order line.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Add any product with *Make To Order* option enabled into a new sale
order.
2. Set *Analytic Distribution*.
3. *Confirm Sale*
4. The generated purchase order line will have this analytic
distribution. They won't be grouped if analytic distribution is
different.

Changelog
=========

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

Migrated to odoo 13.

12.0.1.0.1 (2019-02-19)
-----------------------

[ADD] Add feature to set analytic account for purchase lines of service
products.

12.0.1.0.0 (2019-02-18)
-----------------------

Migrated to odoo 12.

11.0.1.0.0 (2018-11-15)
-----------------------

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:%20procurement_mto_analytic%0Aversion:%2017.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
-------

* Tecnativa
* VentorTech

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

- `Tecnativa <https://www.tecnativa.com>`__:

- Carlos Dauden
- Pedro M. Baeza
- Vicent Cubells

- Ventor-Tech:

- Sergej Lozikov

- `Komit <https://komit-consulting.com/>`__:

- Duc, Dao Dong <duc.dd@komit-consulting.com>

- `Ecosoft <https://ecosoft.co.th/>`__:

- Pimolnat Suntian <pimolnats@ecosoft.co.th>

- `Jarsa <https://www.jarsa.com/>`__:

- Alan Ramos <alan.ramos@jarsa.com>

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.0/procurement_mto_analytic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions procurement_mto_analytic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
14 changes: 14 additions & 0 deletions procurement_mto_analytic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Purchase Analytic (MTO)",
"summary": "This module sets analytic account in purchase order line from "
"sale order analytic account",
"version": "17.0.1.0.0",
"category": "Analytic",
"license": "AGPL-3",
"author": "Tecnativa, VentorTech, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-analytic",
"depends": ["sale_stock", "purchase_stock"],
"installable": True,
}
37 changes: 37 additions & 0 deletions procurement_mto_analytic/i18n/ca.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:
# * procurement_mto_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-09-11 16:02+0000\n"
"Last-Translator: Jaume Planas <jaumeplan@gmail.com>\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 5.6.2\n"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Línia de la comanda de compra"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea de la Comanda de Venda"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_stock_move
msgid "Stock Move"
msgstr "Moviment d'estoc"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_stock_rule
msgid "Stock Rule"
msgstr "Regla d'estoc"
37 changes: 37 additions & 0 deletions procurement_mto_analytic/i18n/es.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:
# * procurement_mto_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-10-29 08:27+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\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"
"X-Generator: Weblate 4.17\n"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_purchase_order_line
msgid "Purchase Order Line"
msgstr "Línea de Orden de Compra"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea del Pedido de Venta"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de Stock"

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_stock_rule
msgid "Stock Rule"
msgstr "Regla de Stock"
34 changes: 34 additions & 0 deletions procurement_mto_analytic/i18n/procurement_mto_analytic.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:
# * procurement_mto_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: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_purchase_order_line
msgid "Purchase Order Line"
msgstr ""

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: procurement_mto_analytic
#: model:ir.model,name:procurement_mto_analytic.model_stock_rule
msgid "Stock Rule"
msgstr ""
30 changes: 30 additions & 0 deletions procurement_mto_analytic/i18n/purchase_procurement_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_procurement_analytic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.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_procurement_analytic
#: model:ir.model,name:purchase_procurement_analytic.model_procurement_rule
msgid "Procurement Rule"
msgstr ""

#. module: purchase_procurement_analytic
#: model:ir.model,name:purchase_procurement_analytic.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: purchase_procurement_analytic
#: model:ir.model,name:purchase_procurement_analytic.model_stock_move
msgid "Stock Move"
msgstr ""

5 changes: 5 additions & 0 deletions procurement_mto_analytic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import sale_order_line
from . import stock_rule
from . import purchase_order
45 changes: 45 additions & 0 deletions procurement_mto_analytic/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import json

from odoo import api, models


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

@api.model
@api.returns("self")
def search(self, domain, offset=0, limit=None, order=None):
new_domain = []
for element in domain:
if element[0] == "order_line.analytic_distribution":
try:
value = json.loads(element[2])
except json.JSONDecodeError:
new_domain.append(element)

Check warning on line 20 in procurement_mto_analytic/models/purchase_order.py

View check run for this annotation

Codecov / codecov/patch

procurement_mto_analytic/models/purchase_order.py#L19-L20

Added lines #L19 - L20 were not covered by tests
new_domain.append(
(
"order_line.analytic_distribution",
"=",
value,
)
)
else:
new_domain.append(element)
return super().search(new_domain, offset=offset, limit=limit, order=order)


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

@api.model
def _prepare_purchase_order_line_from_procurement(
self, product_id, product_qty, product_uom, company_id, values, po
):
res = super()._prepare_purchase_order_line_from_procurement(
product_id, product_qty, product_uom, company_id, values, po
)
if values.get("analytic_distribution", False):
res["analytic_distribution"] = values.get("analytic_distribution", False)
return res
21 changes: 21 additions & 0 deletions procurement_mto_analytic/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

def _prepare_procurement_values(self, group_id=False):
res = super()._prepare_procurement_values(group_id)
if self.analytic_distribution:
res.update({"analytic_distribution": self.analytic_distribution})
return res

def _purchase_service_prepare_line_values(self, purchase_order, quantity=False):
res = super()._purchase_service_prepare_line_values(
purchase_order=purchase_order, quantity=quantity
)
if self.analytic_distribution:
res.update({"analytic_distribution": self.analytic_distribution})
return res
21 changes: 21 additions & 0 deletions procurement_mto_analytic/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import json

from odoo import models


class StockRule(models.Model):
_inherit = "stock.rule"

def _make_po_get_domain(self, company_id, values, partner):
res = super()._make_po_get_domain(company_id, values, partner)
if values.get("analytic_distribution", False):
res += (
(
"order_line.analytic_distribution",
"=",
json.dumps(values.get("analytic_distribution")),
),
)
return res
3 changes: 3 additions & 0 deletions procurement_mto_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"
Loading
Loading