Skip to content

Commit

Permalink
[MIG] delivery_multi_destination: Migration to 17.0
Browse files Browse the repository at this point in the history
TT54925
  • Loading branch information
victoralmau committed Feb 19, 2025
1 parent e126953 commit 8742187
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 78 deletions.
1 change: 1 addition & 0 deletions delivery_multi_destination/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Contributors
- Luis M. Ontalba
- Carlos Roca
- Carolina Fernandez
- Víctor Martínez

- \`Dinamiche Aziendali <https://www.dinamicheaziendali.it>\_\_\`:

Expand Down
4 changes: 2 additions & 2 deletions delivery_multi_destination/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

{
"name": "Multiple destinations for the same delivery method",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Delivery",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": ["delivery"],
"depends": ["stock_delivery"],
"demo": ["demo/delivery_carrier_demo.xml"],
"data": ["views/delivery_carrier_view.xml"],
}
6 changes: 0 additions & 6 deletions delivery_multi_destination/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,3 @@ msgstr "Vereinigtes Königreich"
#: model:product.template,uom_name:delivery_multi_destination.product_product_delivery_carrier_multi_product_template
msgid "Units"
msgstr ""

#~ msgid "Delivery Methods"
#~ msgstr "Liefermethoden"

#~ msgid "kg"
#~ msgstr "kg"
9 changes: 0 additions & 9 deletions delivery_multi_destination/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,3 @@ msgstr "Reino Unido"
#: model:product.template,uom_name:delivery_multi_destination.product_product_delivery_carrier_multi_product_template
msgid "Units"
msgstr "Unidades"

#~ msgid "Delivery Methods"
#~ msgstr "Métodos de entrega"

#~ msgid "Unit(s)"
#~ msgstr "Unidade(s)"

#~ msgid "kg"
#~ msgstr "kg"
3 changes: 0 additions & 3 deletions delivery_multi_destination/i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,3 @@ msgstr ""
#: model:product.template,uom_name:delivery_multi_destination.product_product_delivery_carrier_multi_product_template
msgid "Units"
msgstr ""

#~ msgid "Delivery Methods"
#~ msgstr "Načini dostave"
9 changes: 0 additions & 9 deletions delivery_multi_destination/i18n/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,3 @@ msgstr "英国"
#: model:product.template,uom_name:delivery_multi_destination.product_product_delivery_carrier_multi_product_template
msgid "Units"
msgstr ""

#~ msgid "Delivery Methods"
#~ msgstr "交货方式"

#~ msgid "Unit(s)"
#~ msgstr "件"

#~ msgid "kg"
#~ msgstr "千克"
24 changes: 10 additions & 14 deletions delivery_multi_destination/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,21 @@ def _onchange_destination_type(self):
if self.destination_type == "multi" and self.child_ids and not self.product_id:
self.product_id = fields.first(self.child_ids.product_id)

def search(self, args, offset=0, limit=None, order=None, count=False):
@api.model
def search(self, domain, offset=0, limit=None, order=None):
"""Don't show by default children carriers."""
if not self.env.context.get("show_children_carriers"):
if args is None:
args = []
args += [("parent_id", "=", False)]
return super().search(
args,
offset=offset,
limit=limit,
order=order,
count=count,
)
if domain is None:
domain = []

Check warning on line 40 in delivery_multi_destination/models/delivery_carrier.py

View check run for this annotation

Codecov / codecov/patch

delivery_multi_destination/models/delivery_carrier.py#L40

Added line #L40 was not covered by tests
domain += [("parent_id", "=", False)]
return super().search(domain, offset=offset, limit=limit, order=order)

@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
"""Don't show by default children carriers."""
domain = [("parent_id", "=", False)]
return self.search(domain, limit=limit).name_get()
args = args or []
args += [("parent_id", "=", False)]
return super().name_search(name, args, operator, limit)

def available_carriers(self, partner):
"""If the carrier is multi, we test the availability on children."""
Expand Down Expand Up @@ -92,7 +88,7 @@ def send_shipping(self, pickings):
for p in pickings:
picking_res = False
for subcarrier in carrier.child_ids.filtered(
lambda x: not x.company_id or x.company_id == p.company_id
lambda x, p=p: not x.company_id or x.company_id == p.company_id
):
if subcarrier.delivery_type == "fixed":
if subcarrier._match_address(p.partner_id):
Expand Down
1 change: 1 addition & 0 deletions delivery_multi_destination/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
- Luis M. Ontalba
- Carlos Roca
- Carolina Fernandez
- Víctor Martínez
- \`Dinamiche Aziendali \<<https://www.dinamicheaziendali.it>\>\_\_\`:
- Gianmarco Conte
1 change: 1 addition & 0 deletions delivery_multi_destination/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Luis M. Ontalba</li>
<li>Carlos Roca</li>
<li>Carolina Fernandez</li>
<li>Víctor Martínez</li>
</ul>
</li>
<li>`Dinamiche Aziendali &lt;<a class="reference external" href="https://www.dinamicheaziendali.it">https://www.dinamicheaziendali.it</a>&gt;__`:<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
# Copyright 2019-2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests import Form, common
from odoo.tests import Form
from odoo.tools import mute_logger

from odoo.addons.base.tests.common import BaseCommon

class TestDeliveryMultiDestination(common.TransactionCase):

class TestDeliveryMultiDestination(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.country_1 = cls.env["res.country"].create({"name": "Test country 1"})
cls.country_1 = cls.env["res.country"].create(
{"name": "Test country 1", "code": "T1"}
)
cls.pricelist = cls.env["product.pricelist"].create(
{"name": "Test pricelist", "currency_id": cls.env.company.currency_id.id}
)
Expand All @@ -20,7 +25,9 @@ def setUpClass(cls):
"property_product_pricelist": cls.pricelist.id,
}
)
cls.country_2 = cls.env["res.country"].create({"name": "Test country 2"})
cls.country_2 = cls.env["res.country"].create(
{"name": "Test country 2", "code": "T2"}
)
cls.state = cls.env["res.country.state"].create(
{"name": "Test state", "code": "TS", "country_id": cls.country_2.id}
)
Expand Down Expand Up @@ -76,7 +83,7 @@ def setUpClass(cls):
}
)
cls.product = cls.env["product.product"].create(
{"name": "Test product", "detailed_type": "product", "list_price": 1}
{"name": "Test product", "detailed_type": "consu", "list_price": 1}
)
cls.sale_order = cls._create_sale_order(cls)

Expand Down Expand Up @@ -118,6 +125,7 @@ def _choose_delivery_carrier(self, order, carrier):
choose_delivery_carrier = wizard.save()
choose_delivery_carrier.button_confirm()

@mute_logger("odoo.models.unlink")
def test_delivery_multi_destination(self):
order = self.sale_order
order.carrier_id = self.carrier_single.id
Expand Down Expand Up @@ -163,8 +171,8 @@ def test_picking_validation(self):
self.sale_order.action_confirm()
picking = self.sale_order.picking_ids
self.assertEqual(picking.carrier_id, self.carrier_multi)
picking.move_ids.quantity_done = 1
picking._action_done()
picking.move_ids.quantity = 1
picking.button_validate()
self.assertAlmostEqual(picking.carrier_price, 50)

def test_delivery_carrier_multi_form(self):
Expand Down
43 changes: 15 additions & 28 deletions delivery_multi_destination/views/delivery_carrier_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,34 @@
</group>
</div>
<group name="provider_details" position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '=', 'multi')]}</attribute>
<attribute name="invisible">destination_type=='multi'</attribute>
</group>
<label for="margin" position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '=', 'multi')]}</attribute>
<field name="margin" position="attributes">
<attribute name="invisible">destination_type=='multi'</attribute>
</field>
<label for="free_over" position="attributes">
<attribute name="invisible">destination_type=='multi'</attribute>
</label>
<xpath expr="//field[@name='margin']/.." position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '=', 'multi')]}</attribute>
</xpath>
<xpath expr="//field[@name='free_over']/.." position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '=', 'multi')]}</attribute>
<xpath expr="//div[@name='free_over_amount']" position="attributes">
<attribute name="invisible">destination_type=='multi'</attribute>
</xpath>
<field name="amount" position="attributes">
<attribute name="required">free_over</attribute>
<attribute
name="attrs"
>{'required':[('free_over','!=', False)], 'invisible':['|', ('free_over','=', False), ('destination_type', '=', 'multi')]}</attribute>
name="invisible"
>not free_over or destination_type == 'multi'</attribute>
</field>
<page name="pricing" position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '=', 'multi')]}</attribute>
<attribute name="invisible">destination_type=='multi'</attribute>
</page>
<page name="destination" position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '=', 'multi')]}</attribute>
<attribute name="invisible">destination_type=='multi'</attribute>
</page>
<notebook position="inside">
<page
string="Destinations"
name="page_multi_destination"
attrs="{'invisible': [('destination_type', '!=', 'multi')]}"
invisible="destination_type!='multi'"
>
<field name="child_ids" context="{'show_children_fields': True}" />
</page>
Expand All @@ -66,9 +55,7 @@
<field name="inherit_id" ref="delivery.view_delivery_carrier_tree" />
<field name="arch" type="xml">
<field name="delivery_type" position="attributes">
<attribute
name="attrs"
>{'invisible': [('destination_type', '!=', 'one')]}</attribute>
<attribute name="invisible">destination_type!='one'</attribute>
</field>
<field name="delivery_type" position="after">
<field name="destination_type" />
Expand Down

0 comments on commit 8742187

Please sign in to comment.