Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions delivery_package_number/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ If delivey packages are used:
When the picking is confirmed, the user has the chance to change the
number of packages in the confirmation wizard.

Add extra information to the Delivery package number report

1. Go to *Settings* > *Inventory* > *Section operations*.
2. Check the *Print extra information package label* option.

|CONFIR_EXTRA_INFORMATION|

3. This will allow you to add the sender, carrier and note values to the
report.

|EXAMPLE_REPORT|

4. A field is enabled to enter the height of the report, by default it
is 50.
5. Done, start generating reports

.. |CONFIR_EXTRA_INFORMATION| image:: https://raw.githubusercontent.com/OCA/delivery-carrier/17.0/delivery_package_number/static/img/readme/config_extra_information.png
.. |EXAMPLE_REPORT| image:: https://raw.githubusercontent.com/OCA/delivery-carrier/17.0/delivery_package_number/static/img/readme/example_report.png

Bug Tracker
===========

Expand Down Expand Up @@ -94,6 +113,10 @@ Contributors

- Ángel García de la Chica Herrera <[email protected]>

- `Binhex <https://www.binhex.cloud>`__:

- Edilio Escalona Almira [email protected]

Maintainers
-----------

Expand Down
1 change: 1 addition & 0 deletions delivery_package_number/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import reports
from . import models
from . import wizard
1 change: 1 addition & 0 deletions delivery_package_number/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"reports/report_package_number.xml",
"views/stock_picking_type_views.xml",
"views/stock_picking_views.xml",
"wizard/res_config_settings.xml",
"wizard/stock_number_package_validate_wiz_view.xml",
],
}
3 changes: 3 additions & 0 deletions delivery_package_number/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
> - [Sygel](https://www.sygel.es):
>
> > - Ángel García de la Chica Herrera \<<[email protected]>\>

- [Binhex](https://www.binhex.cloud):
- Edilio Escalona Almira <[email protected]>
24 changes: 19 additions & 5 deletions delivery_package_number/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
If no delivery packages are used:

1. Go to an open picking and click in the *Additional Info* tab.
2. In the *Delivey Information* section you'll find a **Number of
packages** field that you can edit.
1. Go to an open picking and click in the *Additional Info* tab.
2. In the *Delivey Information* section you'll find a **Number of
packages** field that you can edit.

If delivey packages are used:

1. The field will be recomputed depending on the delivery packages used
in the picking although can be edited at convenience later.
1. The field will be recomputed depending on the delivery packages used
in the picking although can be edited at convenience later.

When the picking is confirmed, the user has the chance to change the
number of packages in the confirmation wizard.

Add extra information to the Delivery package number report

1. Go to *Settings* > *Inventory* > *Section operations*.
2. Check the *Print extra information package label* option.

![CONFIR_EXTRA_INFORMATION](../static/img/readme/config_extra_information.png)

3. This will allow you to add the sender, carrier and note values to the report.

![EXAMPLE_REPORT](../static/img/readme/example_report.png)

4. A field is enabled to enter the height of the report, by default it is 50.
5. Done, start generating reports
1 change: 1 addition & 0 deletions delivery_package_number/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import report_package_number
18 changes: 18 additions & 0 deletions delivery_package_number/reports/report_package_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2020 Tecnativa - David Vidal
# Copyright 2023 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class ReportDeliveryPackageNumber(models.AbstractModel):
_name = "report.delivery_package_number.delivery_package_number_report"

def _get_report_values(self, docids, data=None):
picking_ids = self.env["stock.picking"].browse(docids)
extra_information = (
self.env["ir.config_parameter"]
.sudo()
.get_param("delivery_package_number.extra_information_package_label")
)
return {"docs": picking_ids, "extra_information": extra_information}
58 changes: 49 additions & 9 deletions delivery_package_number/reports/report_package_number.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/>
<t t-foreach="doc.number_of_packages" t-as="pack_num">
<div class="page">
<div class="row">
<div class="row" style="padding-top: 5px;">
<div class="col-5" name="logo">
<img
t-if="doc.company_id.logo"
Expand All @@ -32,28 +32,68 @@
</h4>
</div>
</div>


<div
class="row mt-3"
t-if="(doc.company_id.name or doc.carrier_id.name) and extra_information"
>
<div class="col-5 border border-dark rounded" name="remitter">
<h6 class="fw-bold">Remitter:</h6>
<div class="text-center" style="padding: 60px 0;">
<span
t-field="doc.company_id.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'
/>
</div>
</div>
<div class="col-2" />
<div class="col-5 border border-dark rounded" name="carrier">
<h6 class="fw-bold">Carrier:</h6>
<div class="text-center" style="padding: 60px 0;">
<span
t-if="doc.carrier_id"
t-out="doc.carrier_id.name"
/>
<span t-else="">No assigned</span>
</div>
</div>
</div>

<div class="row mt-3">
<div
class="col-5 border border-dark rounded text-center"
style="padding: 60px 0;"
name="client"
>
<span t-field="dest_picking.partner_id" />
<div class="col-5 border border-dark rounded" name="client">
<h6 class="fw-bold">Addressee:</h6>
<div class="text-center" style="padding: 60px 0;">
<span
t-field="dest_picking.partner_id"
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}'
/>
</div>
</div>
<div class="col-2" />
<div
class="col-5 border border-dark rounded"
name="package_number"
>
<h6>Number of packages:</h6>
<div style="font-size: 4em" class="text-center">
<h6 class="fw-bold">Number of packages:</h6>
<div style="font-size: 4em;" class="text-center">
<span t-out="pack_num + 1" />/<span
t-field="doc.number_of_packages"
/>
</div>
</div>
</div>

<div t-if="doc.note and extra_information" class="row mt-3">
<div
class="col-12 text-center"
style="padding-top: 10px;"
name="note"
>
<span style="text-align: justify;" t-field="doc.note" />
</div>
</div>

</div>
<div style="page-break-before:always;" />
</t>
Expand Down
22 changes: 22 additions & 0 deletions delivery_package_number/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,22 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
</ol>
<p>When the picking is confirmed, the user has the chance to change the
number of packages in the confirmation wizard.</p>
<p>Add extra information to the Delivery package number report</p>
<ol class="arabic simple">
<li>Go to <em>Settings</em> &gt; <em>Inventory</em> &gt; <em>Section operations</em>.</li>
<li>Check the <em>Print extra information package label</em> option.</li>
</ol>
<p><img alt="CONFIR_EXTRA_INFORMATION" src="https://raw.githubusercontent.com/OCA/delivery-carrier/17.0/delivery_package_number/static/img/readme/config_extra_information.png" /></p>
<ol class="arabic simple" start="3">
<li>This will allow you to add the sender, carrier and note values to the
report.</li>
</ol>
<p><img alt="EXAMPLE_REPORT" src="https://raw.githubusercontent.com/OCA/delivery-carrier/17.0/delivery_package_number/static/img/readme/example_report.png" /></p>
<ol class="arabic simple" start="4">
<li>A field is enabled to enter the height of the report, by default it
is 50.</li>
<li>Done, start generating reports</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand Down Expand Up @@ -444,6 +460,12 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
</ul>
</blockquote>
</blockquote>
<ul class="simple">
<li><a class="reference external" href="https://www.binhex.cloud">Binhex</a>:<ul>
<li>Edilio Escalona Almira <a class="reference external" href="mailto:e.escalona&#64;binhex.cloud">e.escalona&#64;binhex.cloud</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions delivery_package_number/tests/test_delivery_package_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,31 @@ def test_backorder(self):
new_picking = order.picking_ids - done_picking
self.assertEqual(done_picking.number_of_packages, 2)
self.assertEqual(new_picking.number_of_packages, 0)

def create_settings(self, extra_information=True, page_height=50):
settings = self.env["res.config.settings"].create({})
settings.extra_information_package_label = extra_information
settings.report_package_label_page_height = page_height
settings.execute()
return settings

def test_settings(self):
paperformat = self.env.ref(
"delivery_package_number.paperformat_number_of_packages_label"
)
settings = self.create_settings(page_height=59)
settings._onchange_report_package_label_page_height()
self.assertEqual(paperformat.page_height, 59)

settings = self.create_settings(extra_information=False)
settings._onchange_report_package_label_page_height()
self.assertEqual(paperformat.page_height, 50)

def test_report_delivery_package_number(self):
self.create_settings()
ReportModel = self.env[
"report.delivery_package_number.delivery_package_number_report"
]
result = ReportModel._get_report_values([self.picking.id])
self.assertTrue(result["extra_information"])
self.assertEqual(result["docs"], self.picking)
1 change: 1 addition & 0 deletions delivery_package_number/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import stock_backorder_confirmation
from . import stock_number_package_validate_wiz
from . import res_config_settings
30 changes: 30 additions & 0 deletions delivery_package_number/wizard/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 Ángel García de la Chica Herrera <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

extra_information_package_label = fields.Boolean(
string="Print extra information package label",
config_parameter="delivery_package_number.extra_information_package_label",
)
report_package_label_page_height = fields.Integer(
string="Page height",
default=100,
config_parameter="delivery_package_number.report_package_label_page_height",
)

@api.onchange("report_package_label_page_height", "extra_information_package_label")
def _onchange_report_package_label_page_height(self):
paperformat = self.env.ref(
"delivery_package_number.paperformat_number_of_packages_label"
)
if paperformat:
paperformat.page_height = (
self.report_package_label_page_height
if self.extra_information_package_label is True
else 50
)
30 changes: 30 additions & 0 deletions delivery_package_number/wizard/res_config_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field
name="name"
>res.config.settings.view.form.inherit.delivery.package.number</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//setting[@id='annual_inventory_date']" position="after">
<setting
id="extra_information_package_label"
help="This field allows you to add additional information about the sender (Company),
carrier, and picking note to the 'Delivery package number' report"
>
<field name="extra_information_package_label" />
<div class="mt-2" invisible="not extra_information_package_label">
<field
name="report_package_label_page_height"
class="col flex-grow-0 ml16 mr0 pe-2"
/>
<div class="col ps-3">
<div class="text-muted">The height of the report page</div>
</div>
</div>
</setting>
</xpath>
</field>
</record>
</odoo>