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
1 change: 1 addition & 0 deletions purchase_tag/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import purchase_tag
from . import purchase_order
from . import purchase_order_line
13 changes: 12 additions & 1 deletion purchase_tag/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,27 @@
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import api, fields, models


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

tag_ids = fields.Many2many(
comodel_name="purchase.tag",
compute="_compute_tag_ids",
store=True,
readonly=False,
relation="purchase_order_tag_rel",
column1="purchase_order_id",
column2="tag_id",
string="Tags",
)

@api.depends("order_line.tag_ids")
def _compute_tag_ids(self):
# Add the missing tags from order lines ones
for purchase in self:
for tag in purchase.order_line.tag_ids:
if tag not in purchase.tag_ids:
purchase.tag_ids |= tag
15 changes: 15 additions & 0 deletions purchase_tag/models/purchase_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


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

tag_ids = fields.Many2many(
comodel_name="purchase.tag",
relation="purchase_order_line_tag_rel",
column1="purchase_order_line_id",
column2="tag_id",
string="Tags",
)
11 changes: 11 additions & 0 deletions purchase_tag/views/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
options="{'color_field': 'color', 'no_create_edit': True}"
/>
</field>
<xpath
expr="//field[@name='order_line']/list/field[@name='date_planned']"
position="after"
>
<field
name="tag_ids"
widget="many2many_tags"
options="{'color_field': 'color', 'no_create_edit': True}"
optional="hide"
/>
</xpath>
</field>
</record>

Expand Down