Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] - sale_delivery_state #2361

Open
wants to merge 25 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
74b00e7
[ADD] sale_delivery_state module
PierrickBrun Aug 1, 2018
03fcd20
[IMP] refactor to use a computed field with a close behaviour as invo…
bguillot Sep 30, 2018
37ba3b6
Filter delivery costs that are not considered as delivered
yvaucher Dec 12, 2018
3477a63
Add a button to force the delivery state
yvaucher Dec 12, 2018
f98d745
Add readme content
yvaucher Dec 12, 2018
77b1370
Change Manifest to OCA standards
yvaucher Jan 4, 2019
6ba98ea
Fix xml indent
yvaucher Jan 4, 2019
827297f
[12.0][MIG] migrate module sale_delivery_state to v12
sebastienbeau Oct 9, 2020
95fb804
[IMP] sale_delivery_state: black, isort, prettier
Dec 11, 2020
009c15c
[MIG] sale_delivery_state: Migration to 14.0
Dec 11, 2020
40a2b0a
[FIX] fix function name conflict
sebastienbeau Dec 19, 2020
331e046
sale_delivery_state: refactor tests mock
simahawk Jul 8, 2021
389679e
Update sale_delivery_state/readme/DESCRIPTION.rst
PierrickBrun Jul 9, 2021
fedbed2
[UPD] Update sale_delivery_state.pot
oca-travis Jul 16, 2021
41bdf6b
[UPD] README.rst
OCA-git-bot Jul 16, 2021
4543919
[ADD] icon.png
OCA-git-bot Jul 16, 2021
f0e3617
[IMP] sale_delivery_state: UI similar to Invoice Status
dreispt Oct 16, 2021
4418845
[UPD] README.rst
OCA-git-bot Oct 23, 2021
b04543e
sale_delivery_state 14.0.1.1.0
OCA-git-bot Oct 23, 2021
60898aa
[15.0] [MIG] sale_delivery_state
celm1990 Jan 13, 2022
71294c5
[UPD] Update sale_delivery_state.pot
Jan 13, 2022
65231b2
[UPD] README.rst
OCA-git-bot Jan 13, 2022
aa95f94
[UPD] README.rst
OCA-git-bot Jun 2, 2022
1e6961c
[UPD] README.rst
OCA-git-bot Jun 2, 2022
707632a
[16.0][MIG] - sale_delivery_state
Hardik-OSI Feb 6, 2023
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
92 changes: 92 additions & 0 deletions sale_delivery_state/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
===================
Sale delivery State
===================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/15.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-15-0/sale-workflow-15-0-sale_delivery_state
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/15.0
:alt: Try me on Runbot

|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.

**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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_delivery_state%0Aversion:%2015.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/15.0/sale_delivery_state>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_delivery_state/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
21 changes: 21 additions & 0 deletions sale_delivery_state/__manifest__.py
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",
],
}
35 changes: 35 additions & 0 deletions sale_delivery_state/demo/sale_demo.xml
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>
66 changes: 66 additions & 0 deletions sale_delivery_state/i18n/sale_delivery_state.pot
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 ""
1 change: 1 addition & 0 deletions sale_delivery_state/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import sale_order
89 changes: 89 additions & 0 deletions sale_delivery_state/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 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_state = fields.Selection(
[
("no", "No delivery"),
("unprocessed", "Unprocessed"),
("partially", "Partially processed"),
("done", "Done"),
],
# Compute method have a different name then the field because
# the method _compute_delivery_state already exist to compute
# the field delivery_set
compute="_compute_sale_delivery_state",
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_sale_delivery_state(self):
for order in self:
if order.state in ("draft", "cancel"):
order.delivery_state = "no"
elif order.force_delivery_state or order._all_qty_delivered():
order.delivery_state = "done"
elif order._partially_delivered():
order.delivery_state = "partially"
else:
order.delivery_state = "unprocessed"

def action_force_delivery_state(self):
self.write({"force_delivery_state": True})

def action_unforce_delivery_state(self):
self.write({"force_delivery_state": False})
6 changes: 6 additions & 0 deletions sale_delivery_state/readme/CONTRIBUTORS.rst
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]>
15 changes: 15 additions & 0 deletions sale_delivery_state/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.
Binary file added sale_delivery_state/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading