-
-
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.
Signed-off-by sebastienbeau
- Loading branch information
Showing
29 changed files
with
1,534 additions
and
2 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
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,99 @@ | ||
=================== | ||
Sale delivery State | ||
=================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:5e6de03092efc72436a466046560f3139702a1be2ce615fe519211325e7dd488 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |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 | ||
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_delivery_state | ||
:alt: OCA/sale-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_delivery_state | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This odoo module add delivery state on the sale order. | ||
|
||
Delivery state is computed based on `qty_delivered` field on sale order lines. | ||
|
||
This is usefull for other modules to provide the state of delivery. | ||
The 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. | ||
|
||
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 considered delivered. | ||
Delivery fees lines are ignored in the computation of the delivery state. | ||
|
||
When the 'sale_stock' module is installed, the glue module 'sale_stock_delivery_state' | ||
should also be installed; this module is designed to override the compute method | ||
of the delivery status field from 'sale_stock'. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_. | ||
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 | ||
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_delivery_state%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Akretion | ||
|
||
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]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_delivery_state>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 @@ | ||
from . import models |
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,21 @@ | ||
# Copyright 2018 Akretion (http://www.akretion.com). | ||
# @author Pierrick BRUN <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sale delivery State", | ||
"summary": "Show the delivery state on the sale order", | ||
"version": "16.0.1.0.0", | ||
"category": "Product", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"author": "Akretion, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["sale"], | ||
"data": [ | ||
"views/sale_order_views.xml", | ||
], | ||
"demo": [ | ||
"demo/sale_demo.xml", | ||
], | ||
} |
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,35 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="1"> | ||
|
||
<record id="sale_order_1" model="sale.order"> | ||
<field name="partner_id" ref="base.res_partner_2" /> | ||
<field name="partner_invoice_id" ref="base.res_partner_2" /> | ||
<field name="partner_shipping_id" ref="base.res_partner_2" /> | ||
<field name="user_id" ref="base.user_demo" /> | ||
<field name="pricelist_id" ref="product.list0" /> | ||
<field name="team_id" ref="sales_team.team_sales_department" /> | ||
<field | ||
name="date_order" | ||
eval="(DateTime.today() - relativedelta(months=1)).strftime('%Y-%m-%d %H:%M')" | ||
/> | ||
</record> | ||
|
||
<record id="sale_order_line_1" model="sale.order.line"> | ||
<field name="order_id" ref="sale_order_1" /> | ||
<field name="name">Laptop E5023</field> | ||
<field name="product_id" ref="product.product_product_25" /> | ||
<field name="product_uom_qty">3</field> | ||
<field name="product_uom" ref="uom.product_uom_unit" /> | ||
<field name="price_unit">2950.00</field> | ||
</record> | ||
|
||
<record id="sale_order_line_2" model="sale.order.line"> | ||
<field name="order_id" ref="sale_order_1" /> | ||
<field name="name">Pen drive, 16GB</field> | ||
<field name="product_id" ref="product.product_delivery_02" /> | ||
<field name="product_uom_qty">5</field> | ||
<field name="product_uom" ref="uom.product_uom_unit" /> | ||
<field name="price_unit">145.00</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * sale_delivery_state | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields,help:sale_delivery_state.field_sale_order__force_delivery_state | ||
msgid "" | ||
"Allow to enforce done state of delivery, for instance if some quantities " | ||
"were cancelled" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields,field_description:sale_delivery_state.field_sale_order__delivery_state | ||
msgid "Delivery State" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields.selection,name:sale_delivery_state.selection__sale_order__delivery_state__done | ||
msgid "Done" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields,field_description:sale_delivery_state.field_sale_order__force_delivery_state | ||
msgid "Force Delivery State" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model_terms:ir.ui.view,arch_db:sale_delivery_state.view_order_form_inherit_delivery_state | ||
msgid "Force delivery done" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields.selection,name:sale_delivery_state.selection__sale_order__delivery_state__no | ||
msgid "No delivery" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields.selection,name:sale_delivery_state.selection__sale_order__delivery_state__partially | ||
msgid "Partially processed" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model,name:sale_delivery_state.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model_terms:ir.ui.view,arch_db:sale_delivery_state.view_order_form_inherit_delivery_state | ||
msgid "Unforce delivery done" | ||
msgstr "" | ||
|
||
#. module: sale_delivery_state | ||
#: model:ir.model.fields.selection,name:sale_delivery_state.selection__sale_order__delivery_state__unprocessed | ||
msgid "Unprocessed" | ||
msgstr "" |
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 @@ | ||
from . import sale_order |
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,87 @@ | ||
# Copyright 2018 Akretion (http://www.akretion.com). | ||
# @author Pierrick BRUN <[email protected]> | ||
# Copyright 2018 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
from odoo.tools import float_compare, float_is_zero | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
delivery_status = fields.Selection( | ||
[ | ||
("pending", "Not Delivered"), | ||
("partial", "Partially Delivered"), | ||
("full", "Fully Delivered"), | ||
], | ||
# Compute method have a different name then the field because | ||
# the method _compute_delivery_status already exist in odoo sale_stock | ||
compute="_compute_oca_delivery_status", | ||
store=True, | ||
) | ||
|
||
force_delivery_state = fields.Boolean( | ||
help=( | ||
"Allow to enforce done state of delivery, for instance if some" | ||
" quantities were cancelled" | ||
), | ||
) | ||
|
||
def _all_qty_delivered(self): | ||
""" | ||
Returns True if all line have qty_delivered >= to ordered quantities | ||
If `delivery` module is installed, ignores the lines with delivery costs | ||
:returns: boolean | ||
""" | ||
self.ensure_one() | ||
# Skip delivery costs lines | ||
sale_lines = self.order_line.filtered(lambda rec: not rec._is_delivery()) | ||
precision = self.env["decimal.precision"].precision_get( | ||
"Product Unit of Measure" | ||
) | ||
return all( | ||
float_compare( | ||
line.qty_delivered, line.product_uom_qty, precision_digits=precision | ||
) | ||
>= 0 | ||
for line in sale_lines | ||
) | ||
|
||
def _partially_delivered(self): | ||
""" | ||
Returns True if at least one line is delivered | ||
:returns: boolean | ||
""" | ||
self.ensure_one() | ||
# Skip delivery costs lines | ||
sale_lines = self.order_line.filtered(lambda rec: not rec._is_delivery()) | ||
precision = self.env["decimal.precision"].precision_get( | ||
"Product Unit of Measure" | ||
) | ||
return any( | ||
not float_is_zero(line.qty_delivered, precision_digits=precision) | ||
for line in sale_lines | ||
) | ||
|
||
@api.depends("order_line.qty_delivered", "state", "force_delivery_state") | ||
def _compute_oca_delivery_status(self): | ||
for order in self: | ||
if order.state in ("draft", "cancel"): | ||
order.delivery_status = None | ||
elif order.force_delivery_state or order._all_qty_delivered(): | ||
order.delivery_status = "full" | ||
elif order._partially_delivered(): | ||
order.delivery_status = "partial" | ||
else: | ||
order.delivery_status = "pending" | ||
|
||
def action_force_delivery_state(self): | ||
self.write({"force_delivery_state": True}) | ||
|
||
def action_unforce_delivery_state(self): | ||
self.write({"force_delivery_state": 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* 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]> |
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,19 @@ | ||
This odoo module add delivery state on the sale order. | ||
|
||
Delivery state is computed based on `qty_delivered` field on sale order lines. | ||
|
||
This is usefull for other modules to provide the state of delivery. | ||
The 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. | ||
|
||
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 considered delivered. | ||
Delivery fees lines are ignored in the computation of the delivery state. | ||
|
||
When the 'sale_stock' module is installed, the glue module 'sale_stock_delivery_state' | ||
should also be installed; this module is designed to override the compute method | ||
of the delivery status field from 'sale_stock'. |
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.