Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 99 additions & 0 deletions purchase_sale_link_by_origin/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=============================
Purchase/Sale: link by origin
=============================

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

.. |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/license-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%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/19.0/purchase_sale_link_by_origin
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-purchase_sale_link_by_origin
: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/purchase-workflow&target_branch=19.0
:alt: Try me on Runboat

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

By default since `Odoo
14.0 <https://github.com/odoo/odoo/commit/5a1645a8f8f3560eb778da90b6160b322ce0722e>`__,
PO and SO are linked by their order lines.

This module also link them by the PO's Origin field, to cover more
cases. For example:

- If a user cancels a PO, by default the link would have been broken;
now it won't;
- Or if a user manually defines or updates the Origin field of a PO, it
will be taken into account.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/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/purchase-workflow/issues/new?body=module:%20purchase_sale_link_by_origin%0Aversion:%2019.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
-------

* Camptocamp
* CHEF PIXEL

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

- Phuc (Kieu Hoang) <phuckh@trobz.com>
- `CHEF PIXEL <https://chef-pixel.fr>`__ <hello@chef-pixel.fr>

Other credits
-------------

The development of this module has been financially supported by:

- Camptocamp

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/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/19.0/purchase_sale_link_by_origin>`_ project on GitHub.

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

from . import models
21 changes: 21 additions & 0 deletions purchase_sale_link_by_origin/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Camptocamp SA
# Copyright 2026 CHEF PIXEL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
"name": "Purchase/Sale: link by origin",
"summary": "Link PO/SO by the PO's Origin in addition to the default "
"behavior that only links them by their lines",
"version": "19.0.1.0.0",
"author": "Camptocamp, CHEF PIXEL, Odoo Community Association (OCA)",
"maintainer": "CHEF PIXEL",
"license": "AGPL-3",
"category": "Purchase",
"website": "https://github.com/OCA/purchase-workflow",
"support": "hello@chef-pixel.fr",
"depends": [
"sale_purchase_stock",
],
"data": [],
"application": False,
"installable": True,
}
27 changes: 27 additions & 0 deletions purchase_sale_link_by_origin/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_sale_link_by_origin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-03-19 15:41+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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.17\n"

#. module: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_purchase_order
msgid "Purchase Order"
msgstr "Ordine di acquisto"

#. module: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"
25 changes: 25 additions & 0 deletions purchase_sale_link_by_origin/i18n/pt_BR.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:
# * purchase_sale_link_by_origin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: pt_BR\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: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_sale_order
msgid "Sales Order"
msgstr ""
24 changes: 24 additions & 0 deletions purchase_sale_link_by_origin/i18n/purchase_sale_link_by_origin.pot
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:
# * purchase_sale_link_by_origin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.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_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_sale_order
msgid "Sales Order"
msgstr ""
28 changes: 28 additions & 0 deletions purchase_sale_link_by_origin/i18n/sl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * purchase_sale_link_by_origin
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2026-01-10 08:13+0000\n"
"Last-Translator: Matjaz Mozetic <matjaz@luxim.si>\n"
"Language-Team: none\n"
"Language: sl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || "
"n%100==4 ? 2 : 3;\n"
"X-Generator: Weblate 5.10.4\n"

#. module: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_purchase_order
msgid "Purchase Order"
msgstr "Nabavni nalog"

#. module: purchase_sale_link_by_origin
#: model:ir.model,name:purchase_sale_link_by_origin.model_sale_order
msgid "Sales Order"
msgstr "Prodajni nalog"
6 changes: 6 additions & 0 deletions purchase_sale_link_by_origin/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2023 Camptocamp SA
# Copyright 2026 CHEF PIXEL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from . import purchase_order
from . import sale_order
25 changes: 25 additions & 0 deletions purchase_sale_link_by_origin/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Camptocamp SA
# Copyright 2026 CHEF PIXEL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, models


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

@api.depends("origin")
def _compute_sale_order_count(self):
return super()._compute_sale_order_count()

def _get_sale_orders(self):
origins = set()
for order in self:
if order.origin:
for origin_part in order.origin.split(", "):
if " - " in origin_part:
origins.add(origin_part.split(" - ")[-1].strip())
else:
origins.add(origin_part.strip())
so_origins = self.env["sale.order"].search([["name", "in", list(origins)]])
return super()._get_sale_orders() | so_origins
21 changes: 21 additions & 0 deletions purchase_sale_link_by_origin/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Camptocamp SA
# Copyright 2026 CHEF PIXEL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, models


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

@api.depends("origin")
def _compute_purchase_order_count(self):
return super()._compute_purchase_order_count()

def _get_purchase_orders(self):
po_related = self.env["purchase.order"]
for order in self:
po_related |= self.env["purchase.order"].search(
[("origin", "ilike", order.name)]
)
return super()._get_purchase_orders() | po_related
3 changes: 3 additions & 0 deletions purchase_sale_link_by_origin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions purchase_sale_link_by_origin/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Phuc (Kieu Hoang) \<<phuckh@trobz.com>\>
- [CHEF PIXEL](https://chef-pixel.fr) \<<hello@chef-pixel.fr>\>
3 changes: 3 additions & 0 deletions purchase_sale_link_by_origin/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development of this module has been financially supported by:

- Camptocamp
5 changes: 5 additions & 0 deletions purchase_sale_link_by_origin/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
By default since [Odoo 14.0](https://github.com/odoo/odoo/commit/5a1645a8f8f3560eb778da90b6160b322ce0722e), PO and SO are linked by their order lines.

This module also link them by the PO's Origin field, to cover more cases. For example:
- If a user cancels a PO, by default the link would have been broken; now it won't;
- Or if a user manually defines or updates the Origin field of a PO, it will be taken into account.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading