-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] sale_order_weight: Migration to 16.0 (from 12.0)
[FIX] the weight on sale.order.line is now always correct. Change weight on product now change automatically the weight of the sale orders. So it is not necessary to 'recompute' the weight of the orders, and the value is always correct. (Also the column 'Unit Weight' is removed at sale.order.line level) [FIX] Handle correctly UoM conversion. Use Case : - product.product (weight : 50kg ; Uom : Unit) - sale.order.line (Qty : 10 ; UoM : dozen) -> Before, the weight was 50 * 10 = 500 and was wrong. -> Now the weight is 50 * 10 * 12 = 6000 [MIG] Add script to fix incorrect weight values The values can be incorrect (due to conversion errors), or obsolet (if user didn't click on 'recompute weight') [IMP] Display weight on sale order report. Note: this code comes from the other OCA modules name sale_order_weight, present in the OCA repo sale-reporting, in V14: See: https://github.com/OCA/sale-reporting/tree/14.0/sale_order_weight [IMP] Configuration to display the weight or not on the sale order report. Configuration is available for the total order, and the order on each lines. [REM] remove 'delivered' weight for the following reasons: - The delivered quantity on sale order lines is a non stored field. So, the recompute of the field fails, and the field total_delivered_weight is not updated correctly. - It is legit to want to have only Ordered weight and not Delivered Weight, and the addition of the delivered weight make the database bigger, and the process slower. It is so Better to create a dedicated module for delivered weight
- Loading branch information
1 parent
ee705d1
commit 0aa0b89
Showing
21 changed files
with
336 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,42 @@ Sale Order Weight | |
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module is used to calculate the weight in a sale order. | ||
This module is used to calculate the weight (Ordered Products) in a sale order. | ||
|
||
The weight can be displayed on the sale order report. | ||
|
||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
* Go to "Sales > Configuration > Settings" | ||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_order_weight/static/description/configuration.png | ||
|
||
Display Order weight is checked by default. | ||
|
||
The weight display at line level is hidden by default, to avoid burdening the PDF report. | ||
|
||
Usage | ||
===== | ||
|
||
* Go to a sale order. | ||
|
||
The ordered weights are displayed on each order lines and at order level. | ||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_order_weight/static/description/sale_order_form.png | ||
|
||
Note: The weight are also available on the order tree view. (hidden by default) | ||
|
||
* Print a sale order. | ||
|
||
.. figure:: https://raw.githubusercontent.com/OCA/sale-workflow/16.0/sale_order_weight/static/description/sale_order_report.png | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
|
@@ -51,12 +80,14 @@ Credits | |
Authors | ||
~~~~~~~ | ||
|
||
* GRAP | ||
* Xtendoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Manuel Calero - https://xtendoo.es <[email protected]> | ||
* Sylvain LE GAL | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (C) 2024 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
# pylint: disable=W8150 | ||
from odoo.addons.sale_order_weight import pre_init_hook | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# we recompute the weights because in previous implementation, | ||
# 1) the UoM conversion was not done, so the value could be incorrect | ||
# 2) the recompute was not done when the weight of the product has changed | ||
# so the value could be obsolete. | ||
pre_init_hook(env.cr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# Copyright 2021 Manuel Calero Solís (https://xtendoo.es) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import res_company | ||
from . import res_config_settings | ||
from . import sale_order | ||
from . import sale_order_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
display_line_weight_on_sale_report = fields.Boolean(default=False) | ||
|
||
display_order_weight_on_sale_report = fields.Boolean(default=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
display_line_weight_on_sale_report = fields.Boolean( | ||
related="company_id.display_line_weight_on_sale_report", readonly=False | ||
) | ||
display_order_weight_on_sale_report = fields.Boolean( | ||
related="company_id.display_order_weight_on_sale_report", readonly=False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
* Go to "Sales > Configuration > Settings" | ||
|
||
.. figure:: ../static/description/configuration.png | ||
|
||
Display Order weight is checked by default. | ||
|
||
The weight display at line level is hidden by default, to avoid burdening the PDF report. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* Manuel Calero - https://xtendoo.es <[email protected]> | ||
* Sylvain LE GAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
This module is used to calculate the weight in a sale order. | ||
This module is used to calculate the weight (Ordered Products) in a sale order. | ||
|
||
The weight can be displayed on the sale order report. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
* Go to a sale order. | ||
|
||
The ordered weights are displayed on each order lines and at order level. | ||
|
||
.. figure:: ../static/description/sale_order_form.png | ||
|
||
Note: The weight are also available on the order tree view. (hidden by default) | ||
|
||
* Print a sale order. | ||
|
||
.. figure:: ../static/description/sale_order_report.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- | ||
Copyright 2016 Andrea Cometa - Apulia Software | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/gpl.html). | ||
--> | ||
<odoo> | ||
|
||
<template | ||
id="report_saleorder_document" | ||
inherit_id="sale.report_saleorder_document" | ||
> | ||
|
||
<xpath expr="//t[@t-set='address']" position="after"> | ||
<t | ||
t-set="weight_uom_name" | ||
t-value="doc.env['product.template']._get_weight_uom_name_from_ir_config_parameter()" | ||
/> | ||
<t | ||
t-set="weight_precision" | ||
t-value="(doc.env['product.template']._fields['weight'].get_digits(doc.env) or (None, None))[1]" | ||
/> | ||
<t | ||
t-set="display_line_weight_on_sale_report" | ||
t-value="doc.company_id.display_line_weight_on_sale_report" | ||
/> | ||
<t | ||
t-set="display_order_weight_on_sale_report" | ||
t-value="doc.company_id.display_order_weight_on_sale_report" | ||
/> | ||
</xpath> | ||
|
||
|
||
<xpath | ||
expr="//table[hasclass('o_main_table')]/thead/tr/th[@name='th_priceunit']" | ||
position="after" | ||
> | ||
<t t-if="display_line_weight_on_sale_report"> | ||
<th class="text-right">Weight</th> | ||
</t> | ||
</xpath> | ||
|
||
<xpath | ||
expr="//table[hasclass('o_main_table')]/tbody//tr//td[@name='td_priceunit']" | ||
position="after" | ||
> | ||
<t t-if="display_line_weight_on_sale_report"> | ||
<td class="text-right"> | ||
<t t-set="line_weight" t-value="line.total_ordered_weight" /> | ||
<t t-if="line_weight"> | ||
<span | ||
t-esc="line_weight" | ||
t-options="{'widget': 'float', 'precision': weight_precision}" | ||
/> | ||
<span t-esc="weight_uom_name" /> | ||
</t> | ||
</td> | ||
</t> | ||
</xpath> | ||
|
||
<xpath expr="//t[@t-call='account.document_tax_totals']" position="after"> | ||
<t t-if="display_order_weight_on_sale_report"> | ||
<tr class="border-black o_total"> | ||
<td><strong>Total Weight</strong></td> | ||
<td class="text-end"> | ||
<t t-set="order_weight" t-value="doc.total_ordered_weight" /> | ||
<span | ||
t-esc="order_weight" | ||
t-options="{'widget': 'float', 'precision': weight_precision}" | ||
/> | ||
<span t-esc="weight_uom_name" /> | ||
</td> | ||
</tr> | ||
</t> | ||
</xpath> | ||
|
||
</template> | ||
|
||
</odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.