-
-
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.
[IMP]sale_delivery_state: Skip sale order lines for delivery state
- Loading branch information
1 parent
091d352
commit 0eef364
Showing
12 changed files
with
188 additions
and
34 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ Sale delivery State | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:0ff06f9e489784baf8b25b5d53c355c7c8ade5638a55431b288c216b3520b689 | ||
!! source digest: sha256:df53b074f16b808caf5d41acc70a817089ff3852a2504e53ad9ebb8cf7cbdcdd | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
|
@@ -38,8 +38,14 @@ state of the sale order can be forced to fully delivered in case some | |
quantities were cancelled by the customer and you consider you have | ||
nothing more to deliver. | ||
|
||
Sale order lines can have products or services, as long as the field | ||
qty_delivered is set, it will trigger the computation of delivery state. | ||
Sale order lines can have products or services, as long as the field `qty_delivered` | ||
is set, it will trigger the computation of delivery state. | ||
|
||
Sale order lines with the Skip Delivery State field set to True will be ignored when | ||
computing the delivery state. This field is automatically set depending on the field | ||
Sales > Configuration > Quotations & Orders > Skip Service products for Sale Delivery | ||
State. If set to True, the field Skip Delivery State in sale order lines containing | ||
service products will be automatically set to True, but it can manually changed. | ||
|
||
This module also works with delivery.carrier fees that are added as a | ||
sale order line. Thoses line are special as they will never be | ||
|
@@ -56,6 +62,12 @@ from 'sale_stock'. | |
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
#. Go to *Sales > Configuration > Quotations & Orders*. | ||
#. Check the Skip Service products for Sale Delivery State checkbox to automatically set the field Skip Delivery State in sale order lines to True when the line contains a service product. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
|
@@ -77,12 +89,13 @@ Authors | |
Contributors | ||
------------ | ||
|
||
- Pierrick BRUN <[email protected]> | ||
- Benoît Guillot <[email protected]> | ||
- Yannick Vaucher <[email protected]> | ||
- Daniel Reis <[email protected]>, `Open Source | ||
Integrators <https://opensourceintegrators.com>`__ | ||
- Carlos Lopez <[email protected]> | ||
* Pierrick BRUN <[email protected]> | ||
* Benoît Guillot <[email protected]> | ||
* Yannick Vaucher <[email protected]> | ||
* Daniel Reis <[email protected]>, | ||
`Open Source Integrators <https://opensourceintegrators.com>` | ||
* Carlos Lopez <[email protected]> | ||
* Manuel Regidor <[email protected]> | ||
|
||
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
from . import sale_order | ||
from . import sale_order_line | ||
from . import res_company | ||
from . import res_config_settings |
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,12 @@ | ||
# Copyright 2023 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
skip_service_sale_delivery_state = fields.Boolean( | ||
string="Skip Service products for Sale Delivery State" | ||
) |
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,14 @@ | ||
# Copyright 2023 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
skip_service_sale_delivery_state = fields.Boolean( | ||
string="Skip Service products for Sale Delivery State", | ||
related="company_id.skip_service_sale_delivery_state", | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
# @author Pierrick BRUN <[email protected]> | ||
# Copyright 2018 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
# Copyright 2023 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools import float_compare, float_is_zero | ||
|
@@ -39,7 +41,9 @@ def _all_qty_delivered(self): | |
""" | ||
self.ensure_one() | ||
# Skip delivery costs lines | ||
sale_lines = self.order_line.filtered(lambda rec: not rec._is_delivery()) | ||
sale_lines = self.order_line.filtered( | ||
lambda rec: not rec._is_delivery() and not rec.skip_sale_delivery_state | ||
) | ||
precision = self.env["decimal.precision"].precision_get( | ||
"Product Unit of Measure" | ||
) | ||
|
@@ -59,7 +63,9 @@ def _partially_delivered(self): | |
""" | ||
self.ensure_one() | ||
# Skip delivery costs lines | ||
sale_lines = self.order_line.filtered(lambda rec: not rec._is_delivery()) | ||
sale_lines = self.order_line.filtered( | ||
lambda rec: not rec._is_delivery() and not rec.skip_sale_delivery_state | ||
) | ||
precision = self.env["decimal.precision"].precision_get( | ||
"Product Unit of Measure" | ||
) | ||
|
@@ -68,8 +74,13 @@ def _partially_delivered(self): | |
for line in sale_lines | ||
) | ||
|
||
@api.depends("order_line.qty_delivered", "state", "force_delivery_state") | ||
def _compute_oca_delivery_status(self): | ||
@api.depends( | ||
"order_line.qty_delivered", | ||
"order_line.skip_sale_delivery_state", | ||
"state", | ||
"force_delivery_state", | ||
) | ||
def _compute_sale_delivery_state(self): | ||
for order in self: | ||
if order.state in ("draft", "cancel"): | ||
order.delivery_status = None | ||
|
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,27 @@ | ||
# Copyright 2023 Manuel Regidor <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
skip_sale_delivery_state = fields.Boolean( | ||
string="Skip Delivery State", | ||
compute="_compute_skip_sale_delivery_state", | ||
store=True, | ||
readonly=False, | ||
) | ||
|
||
@api.depends("company_id", "product_id") | ||
def _compute_skip_sale_delivery_state(self): | ||
for line in self: | ||
skip_sale_delivery_state = False | ||
if ( | ||
line.product_id | ||
and line.product_id.type == "service" | ||
and line.company_id.skip_service_sale_delivery_state | ||
): | ||
skip_sale_delivery_state = True | ||
line.skip_sale_delivery_state = skip_sale_delivery_state |
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,2 @@ | ||
#. Go to *Sales > Configuration > Quotations & Orders*. | ||
#. Check the Skip Service products for Sale Delivery State checkbox to automatically set the field Skip Delivery State in sale order lines to True when the line contains a service product. |
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,26 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="sale_delivery_state_res_config_settings_view_form" model="ir.ui.view"> | ||
<field name="name">sale.delivery.state.res.config.settings.view.form</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="sale.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//div[@id='proforma_configuration']" position="after"> | ||
<div | ||
class="col-12 col-lg-6 o_setting_box" | ||
id="skip_service_sale_delivery_state_configuration" | ||
> | ||
<div class="o_setting_left_pane"> | ||
<field name="skip_service_sale_delivery_state" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label for="skip_service_sale_delivery_state" /> | ||
<div class="text-muted"> | ||
If active, sale order lines containing Service products will not be evaluated by default when determining the Delivery State. | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |
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