forked from OCA/delivery-carrier
-
Notifications
You must be signed in to change notification settings - Fork 0
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 pedrobaeza
- Loading branch information
Showing
21 changed files
with
881 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1 @@ | ||
12.0.20190820.0 | ||
12.0.20190822.0 |
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
1 change: 1 addition & 0 deletions
1
...ock_picking_delivery_info_computation/odoo/addons/stock_picking_delivery_info_computation
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 @@ | ||
../../../../stock_picking_delivery_info_computation |
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 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=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,115 @@ | ||
======================================= | ||
Stock Picking Delivery Info Computation | ||
======================================= | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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%2Fdelivery--carrier-lightgray.png?logo=github | ||
:target: https://github.com/OCA/delivery-carrier/tree/12.0/stock_picking_delivery_info_computation | ||
:alt: OCA/delivery-carrier | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/delivery-carrier-12-0/delivery-carrier-12-0-stock_picking_delivery_info_computation | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/99/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends the functionality of delivery to support | ||
calculating the picking weight giving priority to the package operations and | ||
also allowing you to calculate volume manually with same logic. | ||
|
||
On a picking which only has inital demand, calculation will be as standard, | ||
based on the picking lines product quantity. | ||
|
||
As soon as you have any reserved quantity, it will only take them into account. | ||
In this case, the computation of the weight and volume is based in *to do* | ||
quantities, unles you introduce anything in *done* quantity, switching to this | ||
column in that case. | ||
|
||
The volume is auto-computed when the picking is generated from a sales order, | ||
or a backorder is created from original picking, but remains editable for any | ||
possible manual edition. | ||
|
||
You also have a button available for recomputing volume with current data. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to *Inventory > Operations > Transfers* and | ||
pick one not in state *Done* or *Cancelled*. | ||
#. Click on tab *Additional Info* and click on button | ||
*Re-calculate Volume* | ||
|
||
If only has Inital demand volume will be based on the move | ||
lines product *Volume* and *Quantity* but if has *Operations* | ||
only will take in count with two possibilities: | ||
|
||
#. If none operation has *Done* then Volume is calculate | ||
as the sum of operation lines *To Do* quantity. | ||
#. As soon any operation line has total of partial *Done* | ||
quantity only these product volume will be as the | ||
picking volume. | ||
|
||
Weight is always calculate automatic following the standard | ||
but Volume need to click the button to refresh. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/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/delivery-carrier/issues/new?body=module:%20stock_picking_delivery_info_computation%0Aversion:%2012.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 | ||
~~~~~~~ | ||
|
||
* Tecnativa | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Pedro M. Baeza | ||
* Victor M.M. Torres | ||
|
||
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/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/12.0/stock_picking_delivery_info_computation>`_ 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,2 @@ | ||
from . import models | ||
from . import tests |
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 2019 Tecnativa - Victor M.M. Torres | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
'name': 'Stock Picking Delivery Info Computation', | ||
'summary': 'Improve weight and volume calculation', | ||
'version': '12.0.1.0.0', | ||
'category': 'Sales, Stock, Delivery', | ||
'website': 'https://github.com/OCA/delivery-carrier', | ||
'author': 'Tecnativa, Odoo Community Association (OCA)', | ||
'license': 'AGPL-3', | ||
'installable': True, | ||
'depends': [ | ||
'delivery', | ||
], | ||
'data': [ | ||
'views/delivery_view.xml', | ||
'report/report_shipping.xml', | ||
'report/report_deliveryslip.xml', | ||
], | ||
} |
42 changes: 42 additions & 0 deletions
42
stock_picking_delivery_info_computation/i18n/stock_picking_delivery_info_computation.pot
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,42 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * stock_picking_delivery_info_computation | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.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: stock_picking_delivery_info_computation | ||
#: model:ir.ui.view,arch_db:stock_picking_delivery_info_computation.report_delivery_document_info | ||
#: model:ir.ui.view,arch_db:stock_picking_delivery_info_computation.report_shipping_info | ||
msgid "<strong>Packages</strong>" | ||
msgstr "" | ||
|
||
#. module: stock_picking_delivery_info_computation | ||
#: model:ir.ui.view,arch_db:stock_picking_delivery_info_computation.report_delivery_document_info | ||
#: model:ir.ui.view,arch_db:stock_picking_delivery_info_computation.report_shipping_info | ||
msgid "<strong>Volume</strong>" | ||
msgstr "" | ||
|
||
#. module: stock_picking_delivery_info_computation | ||
#: model:ir.ui.view,arch_db:stock_picking_delivery_info_computation.view_picking_withcarrier_out_form | ||
msgid "Re-calculate Volume" | ||
msgstr "" | ||
|
||
#. module: stock_picking_delivery_info_computation | ||
#: model:ir.model,name:stock_picking_delivery_info_computation.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" | ||
|
||
#. module: stock_picking_delivery_info_computation | ||
#: model:ir.model,name:stock_picking_delivery_info_computation.model_stock_picking | ||
msgid "Transfer" | ||
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,2 @@ | ||
from . import sale_order | ||
from . import stock_picking |
13 changes: 13 additions & 0 deletions
13
stock_picking_delivery_info_computation/models/sale_order.py
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 @@ | ||
# Copyright 2019 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = 'sale.order' | ||
|
||
def action_confirm(self): | ||
"""Recompute picking volume when confirming sales order.""" | ||
res = super(SaleOrder, self).action_confirm() | ||
self.mapped('picking_ids').action_calculate_volume() | ||
return res |
55 changes: 55 additions & 0 deletions
55
stock_picking_delivery_info_computation/models/stock_picking.py
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,55 @@ | ||
# Copyright 2019 Tecnativa - Victor M.M. Torres | ||
# Copyright 2019 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, fields, models | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = 'stock.picking' | ||
|
||
number_of_packages = fields.Integer( | ||
string='Number of Packages', | ||
copy=False | ||
) | ||
|
||
@api.depends( | ||
'move_ids_without_package', | ||
'move_ids_without_package.product_id', | ||
'move_ids_without_package.product_uom_qty', | ||
'move_ids_without_package.quantity_done') | ||
def _cal_weight(self): | ||
with_pack_ops = self.filtered('move_ids_without_package') | ||
for rec in self: | ||
has_done = any( | ||
rec.mapped('move_ids_without_package.quantity_done')) | ||
field = 'quantity_done' if has_done else 'product_uom_qty' | ||
rec.weight = sum(rec.move_ids_without_package.mapped( | ||
lambda x: x[field] * x.product_id.weight | ||
)) | ||
super(StockPicking, self - with_pack_ops)._cal_weight() | ||
|
||
@api.multi | ||
def action_calculate_volume(self): | ||
for rec in self: | ||
if rec.move_ids_without_package: | ||
has_done = any( | ||
rec.mapped('move_ids_without_package.quantity_done') | ||
) | ||
field = 'quantity_done' if has_done else 'product_uom_qty' | ||
rec.volume = sum(rec.move_ids_without_package.mapped( | ||
lambda x: x[field] * x.product_id.volume | ||
)) | ||
else: | ||
rec.volume = sum(rec.move_lines.mapped( | ||
lambda x: x.product_uom_qty * x.product_id.volume | ||
)) | ||
|
||
def _create_backorder(self, backorder_moves=None): | ||
"""Compute volume on newly created backorders.""" | ||
if backorder_moves is None: | ||
backorder_moves = [] | ||
backorders = super(StockPicking, self)._create_backorder( | ||
backorder_moves=backorder_moves, | ||
) | ||
backorders.action_calculate_volume() | ||
return backorders |
4 changes: 4 additions & 0 deletions
4
stock_picking_delivery_info_computation/readme/CONTRIBUTORS.rst
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,4 @@ | ||
* `Tecnativa <https://www.tecnativa.com>`_: | ||
|
||
* Pedro M. Baeza | ||
* Victor M.M. Torres |
17 changes: 17 additions & 0 deletions
17
stock_picking_delivery_info_computation/readme/DESCRIPTION.rst
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 @@ | ||
This module extends the functionality of delivery to support | ||
calculating the picking weight giving priority to the package operations and | ||
also allowing you to calculate volume manually with same logic. | ||
|
||
On a picking which only has inital demand, calculation will be as standard, | ||
based on the picking lines product quantity. | ||
|
||
As soon as you have any reserved quantity, it will only take them into account. | ||
In this case, the computation of the weight and volume is based in *to do* | ||
quantities, unles you introduce anything in *done* quantity, switching to this | ||
column in that case. | ||
|
||
The volume is auto-computed when the picking is generated from a sales order, | ||
or a backorder is created from original picking, but remains editable for any | ||
possible manual edition. | ||
|
||
You also have a button available for recomputing volume with current data. |
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 @@ | ||
To use this module, you need to: | ||
|
||
#. Go to *Inventory > Operations > Transfers* and | ||
pick one not in state *Done* or *Cancelled*. | ||
#. Click on tab *Additional Info* and click on button | ||
*Re-calculate Volume* | ||
|
||
If only has Inital demand volume will be based on the move | ||
lines product *Volume* and *Quantity* but if has *Operations* | ||
only will take in count with two possibilities: | ||
|
||
#. If none operation has *Done* then Volume is calculate | ||
as the sum of operation lines *To Do* quantity. | ||
#. As soon any operation line has total of partial *Done* | ||
quantity only these product volume will be as the | ||
picking volume. | ||
|
||
Weight is always calculate automatic following the standard | ||
but Volume need to click the button to refresh. |
13 changes: 13 additions & 0 deletions
13
stock_picking_delivery_info_computation/report/report_deliveryslip.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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<template id="report_delivery_document_info" inherit_id="delivery.report_delivery_document2"> | ||
<xpath expr="//th[@t-if='o.shipping_weight']" position="after"> | ||
<th t-if="o.volume"><strong>Volume</strong></th> | ||
</xpath> | ||
<xpath expr="//td[@t-if='o.shipping_weight']" position="after"> | ||
<td t-if="o.volume"> | ||
<span t-field="o.volume"/> | ||
</td> | ||
</xpath> | ||
</template> | ||
</odoo> |
13 changes: 13 additions & 0 deletions
13
stock_picking_delivery_info_computation/report/report_shipping.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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<template id="report_shipping_info" inherit_id="delivery.report_shipping2"> | ||
<xpath expr="//th[@t-if='o.weight']" position="after"> | ||
<th t-if="o.volume"><strong>Volume</strong></th> | ||
</xpath> | ||
<xpath expr="//td[@t-if='o.weight']" position="after"> | ||
<td t-if="o.volume"> | ||
<span t-field="o.volume"/> | ||
</td> | ||
</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.