Skip to content

Commit

Permalink
[MIG] delivery_carrier_multi_zip: Migration to 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rizzel authored and victoralmau committed Oct 27, 2022
1 parent 44b3082 commit 602b215
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 26 deletions.
2 changes: 1 addition & 1 deletion delivery_carrier_multi_zip/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Multiple ZIP intervals for the same delivery method",
"version": "13.0.1.0.1",
"version": "14.0.1.0.0",
"category": "Delivery",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
91 changes: 91 additions & 0 deletions delivery_carrier_multi_zip/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * delivery_carrier_multi_zip
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-26 23:39+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.2.4\n"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__carrier_id
msgid "Carrier"
msgstr "Spediteur"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__create_uid
msgid "Created by"
msgstr "Angelegt durch"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__create_date
msgid "Created on"
msgstr "Angelegt am"

#. module: delivery_carrier_multi_zip
#: model:ir.model,name:delivery_carrier_multi_zip.model_delivery_carrier_zip
msgid "Delivery destination availability ZIP interval line"
msgstr "Verfügbarer Postleitzahlenbereich für das Lieferziel"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__display_name
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__display_name
msgid "Display Name"
msgstr "Anzeigebezeichnung"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__id
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__id
msgid "ID"
msgstr "ID"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier____last_update
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip____last_update
msgid "Last Modified on"
msgstr "Letzte Änderung am"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__write_uid
msgid "Last Updated by"
msgstr "Zuletzt aktualisiert durch"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__write_date
msgid "Last Updated on"
msgstr "Zuletzt aktualisiert am"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__name
msgid "Name"
msgstr "Bezeichnung"

#. module: delivery_carrier_multi_zip
#: model:ir.model,name:delivery_carrier_multi_zip.model_delivery_carrier
msgid "Shipping Methods"
msgstr "Versandmethoden"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__zip_range_ids
msgid "ZIP codes"
msgstr "Postleitzahlen"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__zip_from
msgid "Zip From"
msgstr "Postleitzahl ab"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__zip_to
msgid "Zip To"
msgstr "Postleitzahl bis"
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-26 23:39+0000\n"
"PO-Revision-Date: 2022-08-26 23:39+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -34,16 +36,19 @@ msgid "Delivery destination availability ZIP interval line"
msgstr ""

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__display_name
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__display_name
msgid "Display Name"
msgstr ""

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__id
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__id
msgid "ID"
msgstr ""

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier____last_update
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip____last_update
msgid "Last Modified on"
msgstr ""
Expand All @@ -69,7 +74,7 @@ msgid "Shipping Methods"
msgstr ""

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__zip_ids
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__zip_range_ids
msgid "ZIP codes"
msgstr ""

Expand Down
11 changes: 7 additions & 4 deletions delivery_carrier_multi_zip/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-21 17:27+0000\n"
"PO-Revision-Date: 2022-04-21 19:29+0200\n"
"POT-Creation-Date: 2022-08-26 23:39+0000\n"
"PO-Revision-Date: 2022-08-27 01:40+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 2.3\n"
"X-Generator: Poedit 2.2.4\n"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__carrier_id
Expand All @@ -38,16 +38,19 @@ msgid "Delivery destination availability ZIP interval line"
msgstr "Línea de intervalo de CP de disponibilidad de destino de transportista"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__display_name
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__id
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip__id
msgid "ID"
msgstr "ID"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier____last_update
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier_zip____last_update
msgid "Last Modified on"
msgstr "Última modificación el"
Expand All @@ -73,7 +76,7 @@ msgid "Shipping Methods"
msgstr "Métodos de envío"

#. module: delivery_carrier_multi_zip
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__zip_ids
#: model:ir.model.fields,field_description:delivery_carrier_multi_zip.field_delivery_carrier__zip_range_ids
msgid "ZIP codes"
msgstr "Códigos postales"

Expand Down
10 changes: 5 additions & 5 deletions delivery_carrier_multi_zip/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class DeliveryCarrier(models.Model):
_inherit = "delivery.carrier"

zip_ids = fields.One2many(
zip_range_ids = fields.One2many(
comodel_name="delivery.carrier.zip",
inverse_name="carrier_id",
string="ZIP codes",
Expand All @@ -18,8 +18,8 @@ def _convert_zip_to_intervals(self, vals):
if self.env.context.get("bypass_multi_zip"):
return
if vals.get("zip_from") or vals.get("zip_to"):
vals.setdefault("zip_ids", [])
vals["zip_ids"].append(
vals.setdefault("zip_range_ids", [])
vals["zip_range_ids"].append(
(
0,
0,
Expand Down Expand Up @@ -47,10 +47,10 @@ def write(self, vals):
def _match_address(self, partner):
"""Match as well by zip intervals if they are present."""
res = super()._match_address(partner) # it has self.ensure_one()
if res and self.zip_ids:
if res and self.zip_range_ids:
partner_zip = partner.zip or ""
res = bool(
self.zip_ids.filtered(
self.zip_range_ids.filtered(
lambda r: r.zip_from <= partner_zip and r.zip_to >= partner_zip
)
)
Expand Down
1 change: 1 addition & 0 deletions delivery_carrier_multi_zip/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>__`:

* Pedro M. Baeza
* Philipp Zimmer
22 changes: 11 additions & 11 deletions delivery_carrier_multi_zip/tests/test_delivery_carrier_multi_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ def setUpClass(cls):
)

def test_delivery_multi_zip_write_create(self):
self.assertEqual(len(self.carrier.zip_ids), 1)
self.assertEqual(self.carrier.zip_ids.zip_from, "0001")
self.assertEqual(self.carrier.zip_ids.zip_to, "0001")
self.assertEqual(len(self.carrier.zip_range_ids), 1)
self.assertEqual(self.carrier.zip_range_ids.zip_from, "0001")
self.assertEqual(self.carrier.zip_range_ids.zip_to, "0001")
self.carrier.write({"zip_to": "0002"})
self.assertEqual(len(self.carrier.zip_ids), 2)
self.assertEqual(self.carrier.zip_ids[1].zip_from, "0")
self.assertEqual(self.carrier.zip_ids[1].zip_to, "0002")
self.assertEqual(len(self.carrier.zip_range_ids), 2)
self.assertEqual(self.carrier.zip_range_ids[1].zip_from, "0")
self.assertEqual(self.carrier.zip_range_ids[1].zip_to, "0002")

def test_post_init_hook(self):
self.carrier.zip_ids.unlink()
self.carrier.zip_range_ids.unlink()
self.carrier.with_context(bypass_multi_zip=True).write({"zip_from": "0002"})
post_init_hook(self.env.cr, None)
self.assertEqual(len(self.carrier.zip_ids), 1)
self.assertEqual(self.carrier.zip_ids.zip_from, "0002")
self.assertEqual(self.carrier.zip_ids.zip_to, "z")
self.assertEqual(len(self.carrier.zip_range_ids), 1)
self.assertEqual(self.carrier.zip_range_ids.zip_from, "0002")
self.assertEqual(self.carrier.zip_range_ids.zip_to, "z")
self.carrier.refresh()
self.assertFalse(self.carrier.zip_from)

def test_available_carriers(self):
self.assertIn(self.carrier, self.carrier.available_carriers(self.partner_1))
self.assertNotIn(self.carrier, self.carrier.available_carriers(self.partner_2))
self.carrier.zip_ids = [(0, 0, {"zip_from": "0002", "zip_to": "0020"})]
self.carrier.zip_range_ids = [(0, 0, {"zip_from": "0002", "zip_to": "0020"})]
self.assertIn(self.carrier, self.carrier.available_carriers(self.partner_2))
6 changes: 3 additions & 3 deletions delivery_carrier_multi_zip/views/delivery_carrier_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<attribute name="invisible">1</attribute>
</group>
<xpath expr="//group[@name='country_details']/.." position="after">
<group name="group_zip_ids" colspan="2">
<field name="zip_ids">
<tree editable="bottom">
<group name="group_zip_range_ids" colspan="2">
<field name="zip_range_ids">
<tree editable="bottom" default_order="zip_from, zip_to">
<field name="zip_from" />
<field name="zip_to" />
</tree>
Expand Down

0 comments on commit 602b215

Please sign in to comment.