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
102 changes: 102 additions & 0 deletions purchase_stock_tag/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
==================
Purchase Stock Tag
==================

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

.. |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%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_stock_tag
: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-18-0/purchase-workflow-18-0-purchase_stock_tag
: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=18.0
:alt: Try me on Runboat

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

This module allows to transmit configured purchase tags on route level
to purchase orders.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

In order to help buyers to review purchase orders, they need to identify
more easily purchase orders created for dedicated flows (e.g.:
Cross-dock, ...).

We'll use purchase tags (that will be put on purchase order lines) in
order to identify those flows coming from the configuration on route
levels.

Configuration
=============

- Go to Inventory > Configuration > Warehouse > Routes
- Fill in the Purchase Tags field.

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_stock_tag%0Aversion:%2018.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
-------

* ACSONE SA/NV

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

- 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.

.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px
:target: https://github.com/rousseldenis
:alt: rousseldenis

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-rousseldenis|

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/18.0/purchase_stock_tag>`_ 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_stock_tag/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions purchase_stock_tag/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Purchase Stock Tag",
"summary": """This module allows to put purchase tags on routes and
reflect them on purchase order lines""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["rousseldenis"],
"website": "https://github.com/OCA/purchase-workflow",
"depends": [
"purchase_tag",
"purchase_stock",
],
"data": ["views/stock_route.xml"],
}
3 changes: 3 additions & 0 deletions purchase_stock_tag/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import stock_route
from . import stock_rule
from . import purchase_order_line
45 changes: 45 additions & 0 deletions purchase_stock_tag/models/purchase_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import Command, api, models


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

@api.model
def _prepare_purchase_order_line_from_procurement(
self,
product_id,
product_qty,
product_uom,
location_dest_id,
name,
origin,
company_id,
values,
po,
):
"""
Add purchase tags coming from route to new purchase line
"""
res = super()._prepare_purchase_order_line_from_procurement(
product_id,
product_qty,
product_uom,
location_dest_id,
name,
origin,
company_id,
values,
po,
)
if "route_ids" in values:
tag_ids = values.get("route_ids").purchase_tag_ids
if tag_ids:
if res.get("tag_ids"):
res["tag_ids"].update(
[Command.link(tag_id.id) for tag_id in tag_ids]
)
else:
res["tag_ids"] = [Command.link(tag_id.id) for tag_id in tag_ids]
return res
18 changes: 18 additions & 0 deletions purchase_stock_tag/models/stock_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockRoute(models.Model):
_inherit = "stock.route"

purchase_tag_ids = fields.Many2many(
comodel_name="purchase.tag",
relation="stock_route_purchase_tag_rel",
column1="stock_route_id",
column2="tag_id",
string="Purchase Tags",
help="Fill in this with purchase tags you want appear "
"on purchase orders generated by this route",
)
32 changes: 32 additions & 0 deletions purchase_stock_tag/models/stock_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import Command, models


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

def _update_purchase_order_line(
self, product_id, product_qty, product_uom, company_id, values, line
):
"""
Add purchase tags coming from route to existing purchase line
"""
res = super()._update_purchase_order_line(
product_id=product_id,
product_qty=product_qty,
product_uom=product_uom,
company_id=company_id,
values=values,
line=line,
)
if "route_ids" in values:
tag_ids = values.get("route_ids").purchase_tag_ids
if tag_ids:
if res.get("tag_ids"):
res["tag_ids"].update(
[Command.link(tag_id.id) for tag_id in tag_ids]
)
else:
res["tag_ids"] = [Command.link(tag_id.id) for tag_id in tag_ids]
return res
3 changes: 3 additions & 0 deletions purchase_stock_tag/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_stock_tag/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Go to Inventory > Configuration > Warehouse > Routes
- Fill in the Purchase Tags field.
5 changes: 5 additions & 0 deletions purchase_stock_tag/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In order to help buyers to review purchase orders, they need to identify more easily
purchase orders created for dedicated flows (e.g.: Cross-dock, ...).

We'll use purchase tags (that will be put on purchase order lines) in order to identify
those flows coming from the configuration on route levels.
1 change: 1 addition & 0 deletions purchase_stock_tag/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <denis.roussel@acsone.eu>
2 changes: 2 additions & 0 deletions purchase_stock_tag/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows to transmit configured purchase tags on route level to
purchase orders.
Binary file added purchase_stock_tag/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading