Skip to content

Commit

Permalink
[MIG] l10n_ch_adr_report: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviedoanhduy committed Oct 15, 2024
1 parent 1a554d1 commit 8962608
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 106 deletions.
3 changes: 3 additions & 0 deletions l10n_ch_adr_report/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ Contributors
- `Trobz <https://trobz.com>`__:

- Son Ho <[email protected]>
- Do Anh Duy <[email protected]>

Other credits
-------------

The development of this module was financially supported by Camptocamp
The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp

Maintainers
-----------
Expand Down
8 changes: 6 additions & 2 deletions l10n_ch_adr_report/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "ADR Products Swiss Report",
"summary": "Print Delivery report to ADR swiss configuration",
"version": "14.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Product",
"website": "https://github.com/OCA/l10n-switzerland",
"author": "Camptocamp, Odoo Community Association (OCA)",
Expand All @@ -13,6 +13,10 @@
"depends": ["l10n_eu_product_adr_dangerous_goods", "stock", "delivery"],
"data": [
"report/DG_ch_delivery_report.xml",
"views/assets.xml",
],
"assets": {
"web.report_assets_common": [
"/l10n_ch_adr_report/static/src/scss/adr_report.scss",
],
},
}
2 changes: 1 addition & 1 deletion l10n_ch_adr_report/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-06 10:55+0000\n"
"PO-Revision-Date: 2020-08-06 10:55+0000\n"
Expand Down
2 changes: 1 addition & 1 deletion l10n_ch_adr_report/i18n/fr.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-03-23 11:10+0000\n"
"PO-Revision-Date: 2021-03-23 11:10+0000\n"
Expand Down
2 changes: 1 addition & 1 deletion l10n_ch_adr_report/i18n/l10n_ch_adr_report.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
25 changes: 12 additions & 13 deletions l10n_ch_adr_report/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,31 @@ class ProductProduct(models.Model):
def _compute_adr_report_class_display_name(self):
for record in self:
adr_good = record.adr_goods_id
res = _("UN")
res += f" {adr_good.un_number}, {adr_good.name}"
res = _(f"UN {adr_good.un_number}, {adr_good.name}")
if record.nag:
res += _(" {}").format(record.nag)
res += _(f" {record.nag}")

if record.label_first:
res += ", {}".format(record._get_name_from_selection("label_first"))
res += f", {record._get_name_from_selection('label_first')}"

if record.label_second and record.label_third:
res += ", ({}, {})".format(
record._get_name_from_selection("label_second"),
record._get_name_from_selection("label_third"),
)
string_label_second = record._get_name_from_selection("label_second")
string_label_third = record._get_name_from_selection("label_third")
res += f", ({string_label_second}, {string_label_third})"
elif record.label_second:
res += ", ({})".format(record._get_name_from_selection("label_second"))
res += f", ({record._get_name_from_selection('label_second')})"

if record.packaging_group:
res += ", {}".format(record._get_name_from_selection("packaging_group"))
res += f", {record._get_name_from_selection('packaging_group')}"

if adr_good.tunnel_restriction_code:
res += ", ({})".format(
record._get_name_from_selection("adr_tunnel_restriction_code")
string_tunnel_restriction_code = record._get_name_from_selection(
"adr_tunnel_restriction_code"
)
res += f", ({string_tunnel_restriction_code})"

if record.envir_hazardous == "yes":
res += ", {}".format(_("Environmentally hazardous"))
res += _("Environmentally hazardous")

record.adr_report_class_display_name = res

Expand Down
5 changes: 3 additions & 2 deletions l10n_ch_adr_report/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
- [Camptocamp](https://www.camptocamp.com):
- [Camptocamp](https://www.camptocamp.com):
- Iryna Vyshnevska \<<[email protected]>\>
- Carlos Serra-Toro \<<[email protected]>\>
- Iryna Vyshnevska \<<[email protected]>\>
- Matthieu Méquignon \<<[email protected]>\>
- Sébastien Alix \<<[email protected]>\>
- Thierry Ducrest \<<[email protected]>\>

- [Trobz](https://trobz.com):
- [Trobz](https://trobz.com):
- Son Ho \<<[email protected]>\>
- Do Anh Duy \<<[email protected]>\>
2 changes: 2 additions & 0 deletions l10n_ch_adr_report/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
The development of this module was financially supported by Camptocamp
The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp
92 changes: 46 additions & 46 deletions l10n_ch_adr_report/report/DG_ch_delivery_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,30 @@
<table class="table table-condensed dg_header">
<thead>
<tr>
<th class="uppercase dg-green" colspan="4">Transportation paper</th>
<th
class="text-uppercase dg-green"
colspan="4"
>Transportation paper</th>
</tr>
</thead>
<tbody>
<tr>
<td>Date</td>
<td>
<t t-if="o.state == 'done'">
<p t-esc="o.date_done.strftime('%Y-%m-%d')" />
<p t-out="o.date_done.strftime('%Y-%m-%d')" />
</t>
<t t-if="o.state != 'done'">
<p t-esc="o.scheduled_date.strftime('%Y-%m-%d')" />
<t t-else="">
<p t-out="o.scheduled_date.strftime('%Y-%m-%d')" />
</t>
</td>
<td>Delivery note no.</td>
<td><p t-field="o.origin" /></td>
</tr>
<tr>
<td class="uppercase emphatic">Sender address</td>
<td class="text-uppercase fw-bold">Sender address</td>
<td />
<td class="uppercase emphatic">Recipient address</td>
<td class="text-uppercase fw-bold">Recipient address</td>
<td />
</tr>
<tr>
Expand Down Expand Up @@ -89,8 +92,8 @@
</tr>
</thead>
<tbody>
<tr class="font-weight-bold">
<td class="text-right" colspan="5">Transport category (BK)</td>
<tr class="fw-bold">
<td class="text-end" colspan="5">Transport category (BK)</td>
<td>0</td>
<td>1</td>
<td>2</td>
Expand All @@ -100,40 +103,40 @@
<tr>
<t t-foreach="DG_data['dg_lines']" t-as="line">
<tr>
<td><span t-esc="line['qty_amount']" /></td>
<td><span t-out="line['qty_amount']" /></td>
<td><span
t-field="line['product'].packaging_type_id"
/></td>
<td><span t-field="line['product'].content_package" /></td>
<td t-att-style="'font-size: 12px'"><span
t-esc="line['class']"
t-out="line['class']"
/></td>
<td><span
t-field="line['product'].adr_transport_category"
/></td>
<td>
<t t-if="line['column_index'] == '0'">
<span t-esc="line['dangerous_amount']" />
<span t-out="line['dangerous_amount']" />
</t>
</td>
<td>
<t t-if="line['column_index'] == '1'">
<span t-esc="line['dangerous_amount']" />
<span t-out="line['dangerous_amount']" />
</t>
</td>
<td>
<t t-if="line['column_index'] == '2'">
<span t-esc="line['dangerous_amount']" />
<span t-out="line['dangerous_amount']" />
</t>
</td>
<td>
<t t-if="line['column_index'] == '3'">
<span t-esc="line['dangerous_amount']" />
<span t-out="line['dangerous_amount']" />
</t>
</td>
<td>
<t t-if="line['column_index'] == '4'">
<span t-esc="line['dangerous_amount']" />
<span t-out="line['dangerous_amount']" />
</t>
</td>
</tr>
Expand All @@ -148,45 +151,45 @@
/>
<tr>
<td
class="text-left font-weight-bold"
class="text-start fw-bold"
colspan="5"
>Total of transported units</td>
<td><span t-esc="units['0']" /></td>
<td><span t-esc="units['1']" /></td>
<td><span t-esc="units['2']" /></td>
<td><span t-esc="units['3']" /></td>
<td><span t-esc="units['4']" /></td>
<td><span t-out="units['0']" /></td>
<td><span t-out="units['1']" /></td>
<td><span t-out="units['2']" /></td>
<td><span t-out="units['3']" /></td>
<td><span t-out="units['4']" /></td>
</tr>
<tr>
<td class="text-left font-weight-bold" colspan="5">Factor</td>
<td><span t-esc="factor['0']" /></td>
<td><span t-esc="factor['1']" /></td>
<td><span t-esc="factor['2']" /></td>
<td><span t-esc="factor['3']" /></td>
<td><span t-esc="factor['4']" /></td>
<td class="text-start fw-bold" colspan="5">Factor</td>
<td><span t-out="factor['0']" /></td>
<td><span t-out="factor['1']" /></td>
<td><span t-out="factor['2']" /></td>
<td><span t-out="factor['3']" /></td>
<td><span t-out="factor['4']" /></td>
</tr>
<tr class="font-weight-bold">
<tr class="fw-bold">
<td
class="text-left"
class="text-start"
colspan="5"
>Points per transportation category</td>
<td><span t-esc="mass_points['0']" /></td>
<td><span t-esc="mass_points['1']" /></td>
<td><span t-esc="mass_points['2']" /></td>
<td><span t-esc="mass_points['3']" /></td>
<td><span t-esc="mass_points['4']" /></td>
<td><span t-out="mass_points['0']" /></td>
<td><span t-out="mass_points['1']" /></td>
<td><span t-out="mass_points['2']" /></td>
<td><span t-out="mass_points['3']" /></td>
<td><span t-out="mass_points['4']" /></td>
</tr>
<tr class="font-weight-bold">
<tr class="fw-bold">
<td colspan="5" />
<td colspan="2">Total Points</td>
<t t-if="DG_data['total_section']['warn']">
<td class="dg-red" colspan="3">
<span t-esc="DG_data['total_section']['total_points']" />
<span t-out="DG_data['total_section']['total_points']" />
</td>
</t>
<t t-else="">
<td class="dg-green" colspan="3">
<span t-esc="DG_data['total_section']['total_points']" />
<span t-out="DG_data['total_section']['total_points']" />
</td>
</t>
</tr>
Expand All @@ -195,26 +198,23 @@
</template>

<template id="report_dg_swiss_footer">
<table class="table-clean" style="width:100%;">
<table class="table-clean w-100">
<tbody>
<tr>
<td>Received listed goods in good physical condition
<t t-if="DG_data['total_section']['warn']">
<div
class="fa fa-warning"
style="color:red; background-color: transparent; padding: 0px;"
/>
<i class="fa fa-warning text-danger bg-transparent p-0" />
</t>
</td>
<td class="text-left">Date
<td class="text-start">Date
<t t-if="o.state == 'done'">
<p t-esc="o.date_done.strftime('%Y-%m-%d')" />
<p t-out="o.date_done.strftime('%Y-%m-%d')" />
</t>
<t t-if="o.state != 'done'">
<p t-esc="o.scheduled_date.strftime('%Y-%m-%d')" />
<p t-out="o.scheduled_date.strftime('%Y-%m-%d')" />
</t>
</td>
<td style="width:300px;" class="text-left">Signature:</td>
<td style="width:300px;" class="text-start">Signature:</td>
</tr>
</tbody>
</table>
Expand Down
18 changes: 5 additions & 13 deletions l10n_ch_adr_report/report/dangerous_delivery_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class DangerousDeliverCHADR(models.AbstractModel):
_description = "Dangerous Delivery Report ADR"

def _get_report_values(self, docids, data=None):
docs = self.env["stock.picking"]
data = data or {}
docs = self.env["stock.picking"].browse(docids)
dg_data = self.prepare_DG_data(docs)
Expand Down Expand Up @@ -52,12 +51,12 @@ def prepare_DG_data(self, picking_ids):
}
for pick in picking_ids:
if pick.state == "done":
moves = pick.move_lines.filtered(lambda l: l.state == "done")
moves = pick.move_ids.filtered(lambda m: m.state == "done")
else:
moves = pick.move_lines
moves = pick.move_ids
dangerous_moves = self._filter_dangerous_move(moves)
grouped_moves = groupby(
sorted(dangerous_moves, key=lambda l: l.product_id),
sorted(dangerous_moves, key=lambda m: m.product_id),
lambda r: r.product_id,
)
vals["dg_lines"] += self._get_DG_move_line_vals(grouped_moves)
Expand Down Expand Up @@ -101,9 +100,7 @@ def _apply_rounding(self, amount):
return round(amount, 1)

def _is_limit_exceeded(self, vals):
if vals["total_points"] > 1000.0:
return True
return False
return vals["total_points"] > 1000.0

def _init_total_vals(self, vals):
vals["factor"]["0"] = 0.0
Expand All @@ -116,12 +113,7 @@ def _get_DG_move_line_vals(self, moves):
# unit measurement on stock is not considered
result = []
for product, move_lines in moves:
qty = 0
for rec in move_lines:
if rec.state == "done":
qty += rec.quantity_done
else:
qty += rec.product_uom_qty
qty = sum(line.quantity for line in move_lines)
full_class_name = product.adr_report_class_display_name + (
", {}, {}, {}, {}".format(
qty,
Expand Down
5 changes: 4 additions & 1 deletion l10n_ch_adr_report/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,16 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
</li>
<li><a class="reference external" href="https://trobz.com">Trobz</a>:<ul>
<li>Son Ho &lt;<a class="reference external" href="mailto:sonhd&#64;trobz.com">sonhd&#64;trobz.com</a>&gt;</li>
<li>Do Anh Duy &lt;<a class="reference external" href="mailto:duyda&#64;trobz.com">duyda&#64;trobz.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
<p>The development of this module was financially supported by Camptocamp</p>
<p>The development of this module was financially supported by Camptocamp
The migration of this module from 14.0 to 18.0 was financially supported
by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
Expand Down
Loading

0 comments on commit 8962608

Please sign in to comment.