Skip to content
Merged
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
11 changes: 6 additions & 5 deletions sale_elaboration/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

================
Sale Elaboration
================
Expand All @@ -17,7 +13,7 @@ Sale Elaboration
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
.. |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%2Fsale--workflow-lightgray.png?logo=github
Expand Down Expand Up @@ -75,6 +71,11 @@ To configure this module you need to:
You can define elaboration profiles to limit the elaborations that can
be selected for each product.

If you want to prevent the elaboration note from being filled
automatically from the selected elaborations, set the system parameter
``sale_elaboration.auto_notes`` to a falsey value in *Settings >
Technical > Parameters > System Parameters*.

To set the profile globally for a product category:

1. Go to *Inventory > Configuration > Product Categories* and choose
Expand Down
7 changes: 7 additions & 0 deletions sale_elaboration/models/product_elaboration_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright 2023 Tecnativa - Carlos Dauden
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.tools.misc import str2bool


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

Expand Down
5 changes: 5 additions & 0 deletions sale_elaboration/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ To configure this module you need to:
You can define elaboration profiles to limit the elaborations that can be
selected for each product.

If you want to prevent the elaboration note from being filled automatically
from the selected elaborations, set the system parameter
`sale_elaboration.auto_notes` to a falsey value in
*Settings > Technical > Parameters > System Parameters*.

To set the profile globally for a product category:

1. Go to *Inventory > Configuration > Product Categories* and choose one.
Expand Down
34 changes: 16 additions & 18 deletions sale_elaboration/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Sale Elaboration</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="sale-elaboration">
<h1 class="title">Sale Elaboration</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="sale-elaboration">
<h1>Sale Elaboration</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2f3ad2d040080e73054832d2a8f210069db12071994aac8fcf8ca85173497ad7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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>
<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>
<p>This module extends the functionality of sales orders to allow to set an
elaboration on lines that will add an extra order line with an
elaboration product linked to it when the delivery order is validated.</p>
Expand All @@ -401,13 +396,13 @@ <h1>Sale Elaboration</h1>
</ul>
</div>
<div class="section" id="use-cases-context">
<h2><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
<p>This module was created to meet the need of providing the customer with
products that are not transformed into something new, but rather require
a simple preparation process. Example: Scaling a fish</p>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<p>To configure this module you need to:</p>
<ol class="arabic simple">
<li>Go to <em>Sale &gt; Configuration &gt; Elaborations &gt; Sale Elaboration</em>.</li>
Expand All @@ -422,6 +417,10 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
</ol>
<p>You can define elaboration profiles to limit the elaborations that can
be selected for each product.</p>
<p>If you want to prevent the elaboration note from being filled
automatically from the selected elaborations, set the system parameter
<tt class="docutils literal">sale_elaboration.auto_notes</tt> to a falsey value in <em>Settings &gt;
Technical &gt; Parameters &gt; System Parameters</em>.</p>
<p>To set the profile globally for a product category:</p>
<ol class="arabic simple">
<li>Go to <em>Inventory &gt; Configuration &gt; Product Categories</em> and choose
Expand All @@ -439,7 +438,7 @@ <h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
</ol>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<ol class="arabic simple">
<li>Go to <em>Sale &gt; Quotations</em>.</li>
<li>Create a sales order.</li>
Expand All @@ -455,23 +454,23 @@ <h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
</ol>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/issues">GitHub Issues</a>.
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
<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>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Sergio Teruel</li>
Expand All @@ -485,7 +484,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
</ul>
</div>
<div class="section" id="maintainers">
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand All @@ -500,6 +499,5 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
11 changes: 11 additions & 0 deletions sale_elaboration/tests/test_sale_elaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ def test_sale_elaboration_doesnt_change(self):
self.order.order_line.elaboration_ids = self.elaboration_b
self.assertEqual(self.order.order_line.elaboration_note, "Some details")

def test_sale_elaboration_onchange_disallow_auto_notes(self):
self.env["ir.config_parameter"].sudo().set_param(
"sale_elaboration.auto_notes", "0"
)
order_form = Form(self.order)
with order_form.order_line.new() as line_form:
line_form.product_id = self.product
line_form.product_uom_qty = 1
line_form.elaboration_ids.add(self.elaboration_a)
self.assertFalse(line_form.elaboration_note)

def test_sale_elaboration(self):
self.order.action_confirm()
self.order.picking_ids.move_ids.quantity = 10.0
Expand Down
Loading