Skip to content

Commit 1b31922

Browse files
committed
Merge PR #3858 into 17.0
Signed-off-by rafaelbn
2 parents 2f1664b + b7a4bc9 commit 1b31922

File tree

11 files changed

+145
-5
lines changed

11 files changed

+145
-5
lines changed

sale_elaboration/README.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,30 @@ To configure this module you need to:
5050
1. Go to *Sale > Configuration > Products > Sale Elaboration*.
5151
2. Create a new record.
5252
3. Set a product linked to the elaboration.
53-
4. Also you can select a route to procure this elaboration.
53+
4. If you use Multi-Step Routes, you can also select a route to procure
54+
this elaboration.
55+
5. Go to *Settings > Inventory > Traceability* and select *Display
56+
Elaboration notes on Delivery Slips* if you want to show elaborations
57+
on Delivery Slips or *Display Elaboration notes on Picking
58+
Operations* if you want to show elaborations on Picking Operations.
59+
60+
You can define elaboration profiles to limit the elaborations that can
61+
be selected for each product.
62+
63+
To set the profile globally for a product category:
64+
65+
1. Go to *Inventory > Configuration > Product Categories* and choose
66+
one.
67+
2. In the **Logistics** sections, you can set the desired **Elaboration
68+
profile**.
69+
70+
If you want to set an specific elaboration profile for a product:
71+
72+
1. Go to *Sale > Configuration > Elaborations > Sale Elaboration
73+
Profile*.
74+
2. Create a new record.
75+
3. Select the elaborations included to the profile.
76+
4. Set the elaboration to the related products.
5477

5578
Usage
5679
=====

sale_elaboration/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"reports/report_base.xml",
2828
"reports/report_deliveryslip.xml",
2929
"reports/report_picking_operations.xml",
30+
"views/product_category_views.xml",
3031
],
3132
"pre_init_hook": "pre_init_hook",
3233
"maintainers": ["CarlosRoca13", "rafaelbn", "sergio-teruel", "yajo"],

sale_elaboration/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
22
from . import product
3+
from . import product_category
34
from . import product_elaboration
45
from . import product_elaboration_mixin
56
from . import product_elaboration_profile

sale_elaboration/models/product.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ class ProductProduct(models.Model):
77
_inherit = "product.product"
88

99
elaboration_profile_id = fields.Many2one(
10-
comodel_name="product.elaboration.profile", ondelete="restrict"
10+
comodel_name="product.elaboration.profile",
11+
ondelete="restrict",
12+
help="Keep this field empty to use the default value from the product "
13+
"category.",
1114
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2025 Moduon Team S.L. <info@moduon.team>
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class ProductCategory(models.Model):
7+
_inherit = "product.category"
8+
9+
elaboration_profile_id = fields.Many2one(
10+
comodel_name="product.elaboration.profile", string="Elaboration Profile"
11+
)

sale_elaboration/models/product_template.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class ProductTemplate(models.Model):
1212
compute="_compute_elaboration_profile_id",
1313
inverse="_inverse_elaboration_profile_id",
1414
store=True,
15+
help="Keep this field empty to use the default value from the product "
16+
"category.",
1517
)
1618

1719
@api.depends("product_variant_ids", "product_variant_ids.elaboration_profile_id")

sale_elaboration/models/sale_order.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class SaleOrderLine(models.Model):
4848
date_order = fields.Datetime(related="order_id.date_order", string="Date")
4949
route_id = fields.Many2one(compute="_compute_route_id", store=True, readonly=False)
5050
elaboration_profile_id = fields.Many2one(
51-
related="product_id.elaboration_profile_id"
51+
comodel_name="product.elaboration.profile",
52+
compute="_compute_elaboration_profile_id",
5253
)
5354
elaboration_price_unit = fields.Float(
5455
"Elab. Price", compute="_compute_elaboration_price_unit", store=True
@@ -59,6 +60,16 @@ class SaleOrderLine(models.Model):
5960
help=("Dummy field to be able to find prepared lines"),
6061
)
6162

63+
@api.depends("product_id")
64+
def _compute_elaboration_profile_id(self):
65+
"""Order of applicability: product profile > category profile > no profile"""
66+
self.elaboration_profile_id = False
67+
for line in self.filtered("product_id"):
68+
line.elaboration_profile_id = (
69+
line.product_id.elaboration_profile_id
70+
or line.product_id.categ_id.elaboration_profile_id
71+
)
72+
6273
def get_elaboration_stock_route(self):
6374
self.ensure_one()
6475
return self.elaboration_ids.route_ids[:1]

sale_elaboration/readme/CONFIGURE.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,25 @@ To configure this module you need to:
33
1. Go to *Sale \> Configuration \> Products \> Sale Elaboration*.
44
2. Create a new record.
55
3. Set a product linked to the elaboration.
6-
4. Also you can select a route to procure this elaboration.
6+
4. If you use Multi-Step Routes, you can also select a route to procure
7+
this elaboration.
8+
5. Go to *Settings \> Inventory \> Traceability* and select *Display
9+
Elaboration notes on Delivery Slips* if you want to show
10+
elaborations on Delivery Slips or *Display Elaboration notes on
11+
Picking Operations* if you want to show elaborations on Picking
12+
Operations.
13+
14+
You can define elaboration profiles to limit the elaborations that can be
15+
selected for each product.
16+
17+
To set the profile globally for a product category:
18+
19+
1. Go to *Inventory > Configuration > Product Categories* and choose one.
20+
2. In the **Logistics** sections, you can set the desired **Elaboration profile**.
21+
22+
If you want to set an specific elaboration profile for a product:
23+
24+
1. Go to *Sale \> Configuration \> Elaborations \> Sale Elaboration Profile*.
25+
2. Create a new record.
26+
3. Select the elaborations included to the profile.
27+
4. Set the elaboration to the related products.

sale_elaboration/static/description/index.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,29 @@ <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
398398
<li>Go to <em>Sale &gt; Configuration &gt; Products &gt; Sale Elaboration</em>.</li>
399399
<li>Create a new record.</li>
400400
<li>Set a product linked to the elaboration.</li>
401-
<li>Also you can select a route to procure this elaboration.</li>
401+
<li>If you use Multi-Step Routes, you can also select a route to procure
402+
this elaboration.</li>
403+
<li>Go to <em>Settings &gt; Inventory &gt; Traceability</em> and select <em>Display
404+
Elaboration notes on Delivery Slips</em> if you want to show elaborations
405+
on Delivery Slips or <em>Display Elaboration notes on Picking
406+
Operations</em> if you want to show elaborations on Picking Operations.</li>
407+
</ol>
408+
<p>You can define elaboration profiles to limit the elaborations that can
409+
be selected for each product.</p>
410+
<p>To set the profile globally for a product category:</p>
411+
<ol class="arabic simple">
412+
<li>Go to <em>Inventory &gt; Configuration &gt; Product Categories</em> and choose
413+
one.</li>
414+
<li>In the <strong>Logistics</strong> sections, you can set the desired <strong>Elaboration
415+
profile</strong>.</li>
416+
</ol>
417+
<p>If you want to set an specific elaboration profile for a product:</p>
418+
<ol class="arabic simple">
419+
<li>Go to <em>Sale &gt; Configuration &gt; Elaborations &gt; Sale Elaboration
420+
Profile</em>.</li>
421+
<li>Create a new record.</li>
422+
<li>Select the elaborations included to the profile.</li>
423+
<li>Set the elaboration to the related products.</li>
402424
</ol>
403425
</div>
404426
<div class="section" id="usage">

sale_elaboration/tests/test_sale_elaboration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright 2018 Tecnativa - Sergio Teruel
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import Command
34
from odoo.tests import Form, tagged
45

56
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
@@ -11,9 +12,21 @@ class TestSaleElaboration(AccountTestInvoicingCommon):
1112
def setUpClass(cls):
1213
super().setUpClass()
1314
cls.Elaboration = cls.env["product.elaboration"]
15+
cls.ElaborationProfile = cls.env["product.elaboration.profile"]
16+
cls.category_1 = cls.env["product.category"].create({"name": "Meat"})
17+
cls.category_2 = cls.env["product.category"].create({"name": "Fish"})
1418
cls.product = cls.env["product.product"].create(
1519
{"name": "test", "tracking": "none", "list_price": 1000}
1620
)
21+
cls.product_2 = cls.env["product.product"].create(
22+
{"name": "test 2", "tracking": "none", "list_price": 1000}
23+
)
24+
cls.product_3 = cls.env["product.product"].create(
25+
{"name": "test 2", "tracking": "none", "list_price": 1000}
26+
)
27+
cls.product.categ_id = cls.category_1
28+
cls.product_2.categ_id = cls.category_2
29+
cls.product_3.categ_id = cls.category_1
1730
cls.product_elaboration_A = cls.env["product.product"].create(
1831
{
1932
"name": "Product Elaboration A",
@@ -65,9 +78,25 @@ def setUpClass(cls):
6578
"product_id": cls.product_elaboration_B.id,
6679
}
6780
)
81+
cls.elaboration_profile_a = cls.ElaborationProfile.create(
82+
{
83+
"name": "Elaboration Profile A",
84+
"elaboration_ids": [
85+
Command.set([cls.elaboration_a.id, cls.elaboration_b.id])
86+
],
87+
}
88+
)
89+
cls.elaboration_profile_b = cls.ElaborationProfile.create(
90+
{
91+
"name": "Elaboration Profile B",
92+
"elaboration_ids": [Command.set(cls.elaboration_a.ids)],
93+
}
94+
)
95+
cls.product.elaboration_profile_id = cls.elaboration_profile_a
6896
cls.order = cls._create_sale_order(
6997
cls, [(cls.product, 10, [cls.elaboration_a])]
7098
)
99+
cls.category_1.elaboration_profile_id = cls.elaboration_profile_b
71100

72101
def _create_sale_order(self, products_info):
73102
order_form = Form(self.env["sale.order"])

0 commit comments

Comments
 (0)