Skip to content

Commit 78de239

Browse files
committed
Merge PR OCA#4228 into 18.0
Signed-off-by yajo
2 parents 64e0a7a + 092de39 commit 78de239

File tree

5 files changed

+45
-23
lines changed

5 files changed

+45
-23
lines changed

sale_elaboration/README.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
================
62
Sale Elaboration
73
================
@@ -17,7 +13,7 @@ Sale Elaboration
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Production/Stable
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
@@ -75,6 +71,11 @@ To configure this module you need to:
7571
You can define elaboration profiles to limit the elaborations that can
7672
be selected for each product.
7773

74+
If you want to prevent the elaboration note from being filled
75+
automatically from the selected elaborations, set the system parameter
76+
``sale_elaboration.auto_notes`` to a falsey value in *Settings >
77+
Technical > Parameters > System Parameters*.
78+
7879
To set the profile globally for a product category:
7980

8081
1. Go to *Inventory > Configuration > Product Categories* and choose

sale_elaboration/models/product_elaboration_mixin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright 2023 Tecnativa - Carlos Dauden
33
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
44
from odoo import api, fields, models
5+
from odoo.tools.misc import str2bool
56

67

78
class ProductElaborationMixin(models.AbstractModel):
@@ -24,6 +25,12 @@ def onchange_elaboration_ids(self):
2425
"""Use onchange method instead of compute because if any other data of any line
2526
force a recompute of all lines and the elaboration custom notes are reset.
2627
"""
28+
if not str2bool(
29+
self.env["ir.config_parameter"]
30+
.sudo()
31+
.get_param("sale_elaboration.auto_notes", True)
32+
):
33+
return
2734
for line in self:
2835
line.elaboration_note = ", ".join(line.elaboration_ids.mapped("name"))
2936

sale_elaboration/readme/CONFIGURE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ To configure this module you need to:
1414
You can define elaboration profiles to limit the elaborations that can be
1515
selected for each product.
1616

17+
If you want to prevent the elaboration note from being filled automatically
18+
from the selected elaborations, set the system parameter
19+
`sale_elaboration.auto_notes` to a falsey value in
20+
*Settings > Technical > Parameters > System Parameters*.
21+
1722
To set the profile globally for a product category:
1823

1924
1. Go to *Inventory > Configuration > Product Categories* and choose one.

sale_elaboration/static/description/index.html

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Sale Elaboration</title>
77
<style type="text/css">
88

99
/*
@@ -360,21 +360,16 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document">
363+
<div class="document" id="sale-elaboration">
364+
<h1 class="title">Sale Elaboration</h1>
364365

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="sale-elaboration">
370-
<h1>Sale Elaboration</h1>
371366
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372367
!! This file is generated by oca-gen-addon-readme !!
373368
!! changes will be overwritten. !!
374369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375370
!! source digest: sha256:2f3ad2d040080e73054832d2a8f210069db12071994aac8fcf8ca85173497ad7
376371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/18.0/sale_elaboration"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_elaboration"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-workflow/tree/18.0/sale_elaboration"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-workflow-18-0/sale-workflow-18-0-sale_elaboration"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378373
<p>This module extends the functionality of sales orders to allow to set an
379374
elaboration on lines that will add an extra order line with an
380375
elaboration product linked to it when the delivery order is validated.</p>
@@ -401,13 +396,13 @@ <h1>Sale Elaboration</h1>
401396
</ul>
402397
</div>
403398
<div class="section" id="use-cases-context">
404-
<h2><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h2>
399+
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
405400
<p>This module was created to meet the need of providing the customer with
406401
products that are not transformed into something new, but rather require
407402
a simple preparation process. Example: Scaling a fish</p>
408403
</div>
409404
<div class="section" id="configuration">
410-
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
405+
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
411406
<p>To configure this module you need to:</p>
412407
<ol class="arabic simple">
413408
<li>Go to <em>Sale &gt; Configuration &gt; Elaborations &gt; Sale Elaboration</em>.</li>
@@ -422,6 +417,10 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
422417
</ol>
423418
<p>You can define elaboration profiles to limit the elaborations that can
424419
be selected for each product.</p>
420+
<p>If you want to prevent the elaboration note from being filled
421+
automatically from the selected elaborations, set the system parameter
422+
<tt class="docutils literal">sale_elaboration.auto_notes</tt> to a falsey value in <em>Settings &gt;
423+
Technical &gt; Parameters &gt; System Parameters</em>.</p>
425424
<p>To set the profile globally for a product category:</p>
426425
<ol class="arabic simple">
427426
<li>Go to <em>Inventory &gt; Configuration &gt; Product Categories</em> and choose
@@ -439,7 +438,7 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
439438
</ol>
440439
</div>
441440
<div class="section" id="usage">
442-
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
441+
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
443442
<ol class="arabic simple">
444443
<li>Go to <em>Sale &gt; Quotations</em>.</li>
445444
<li>Create a sales order.</li>
@@ -455,23 +454,23 @@ <h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
455454
</ol>
456455
</div>
457456
<div class="section" id="bug-tracker">
458-
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
457+
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
459458
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/issues">GitHub Issues</a>.
460459
In case of trouble, please check there if your issue has already been reported.
461460
If you spotted it first, help us to smash it by providing a detailed and welcomed
462461
<a class="reference external" href="https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_elaboration%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
463462
<p>Do not contact contributors directly about support or help with technical issues.</p>
464463
</div>
465464
<div class="section" id="credits">
466-
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
465+
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
467466
<div class="section" id="authors">
468-
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
467+
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
469468
<ul class="simple">
470469
<li>Tecnativa</li>
471470
</ul>
472471
</div>
473472
<div class="section" id="contributors">
474-
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
473+
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
475474
<ul class="simple">
476475
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
477476
<li>Sergio Teruel</li>
@@ -485,7 +484,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
485484
</ul>
486485
</div>
487486
<div class="section" id="maintainers">
488-
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
487+
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
489488
<p>This module is maintained by the OCA.</p>
490489
<a class="reference external image-reference" href="https://odoo-community.org">
491490
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -500,6 +499,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
500499
</div>
501500
</div>
502501
</div>
503-
</div>
504502
</body>
505503
</html>

sale_elaboration/tests/test_sale_elaboration.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ def test_sale_elaboration_doesnt_change(self):
120120
self.order.order_line.elaboration_ids = self.elaboration_b
121121
self.assertEqual(self.order.order_line.elaboration_note, "Some details")
122122

123+
def test_sale_elaboration_onchange_disallow_auto_notes(self):
124+
self.env["ir.config_parameter"].sudo().set_param(
125+
"sale_elaboration.auto_notes", "0"
126+
)
127+
order_form = Form(self.order)
128+
with order_form.order_line.new() as line_form:
129+
line_form.product_id = self.product
130+
line_form.product_uom_qty = 1
131+
line_form.elaboration_ids.add(self.elaboration_a)
132+
self.assertFalse(line_form.elaboration_note)
133+
123134
def test_sale_elaboration(self):
124135
self.order.action_confirm()
125136
self.order.picking_ids.move_ids.quantity = 10.0

0 commit comments

Comments
 (0)