diff --git a/delivery_price_method/README.rst b/delivery_price_method/README.rst new file mode 100644 index 0000000000..4087b1f5d1 --- /dev/null +++ b/delivery_price_method/README.rst @@ -0,0 +1,99 @@ +===================== +Delivery Price Method +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9e406eb0c466c558727db259162fdbbd504bd03b03bea0d218c2e8d799b55012 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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/16.0/delivery_price_method + :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-16-0/delivery-carrier-16-0-delivery_price_method + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to force a local price rate computation for any delivery +method, including those that have been created to query a webservice for +fetching the rate. + +It uses the existing fixed price or price based on rules computations. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *Sales > Configuration > Sales Orders > Delivery Methods*. +#. Open or create a new one. +#. On the "Price Method" field, select "Fixed Price" or "Based on Rules". +#. You will see standard fields for selecting the price as if the delivery + method isn't an integration carrier. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Trey (www.trey.es) + +Contributors +~~~~~~~~~~~~ + +* `Trey `_: + + * Roberto Lizana + +* `Tecnativa `_: + + * Pedro M. Baeza + +* `QubiQ 2010 `_: + + * Marçal Isern + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/delivery_price_method/__init__.py b/delivery_price_method/__init__.py new file mode 100644 index 0000000000..7772e8bfd7 --- /dev/null +++ b/delivery_price_method/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2020 Trey, Kilobytes de Soluciones +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/delivery_price_method/__manifest__.py b/delivery_price_method/__manifest__.py new file mode 100644 index 0000000000..2173053816 --- /dev/null +++ b/delivery_price_method/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 Trey, Kilobytes de Soluciones +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Delivery Price Method", + "summary": "Provides fields to be able to contemplate the tracking states" + "and also adds a global fields", + "author": "Trey (www.trey.es), " "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/delivery-carrier", + "license": "AGPL-3", + "development_status": "Production/Stable", + "category": "Delivery", + "version": "17.0.1.0.0", + "depends": ["stock_delivery"], + "data": ["views/delivery_carrier_views.xml"], +} diff --git a/delivery_price_method/i18n/delivery_price_method.pot b/delivery_price_method/i18n/delivery_price_method.pot new file mode 100644 index 0000000000..60d21d2abe --- /dev/null +++ b/delivery_price_method/i18n/delivery_price_method.pot @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * delivery_price_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__base_on_rule +msgid "Based on Rules" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__carrier +msgid "Carrier obtained price" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__fixed +msgid "Fixed price" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model.fields,field_description:delivery_price_method.field_delivery_carrier__price_method +msgid "Price method" +msgstr "" + +#. module: delivery_price_method +#: model_terms:ir.ui.view,arch_db:delivery_price_method.view_delivery_carrier_form +msgid "Pricing" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model,name:delivery_price_method.model_delivery_carrier +msgid "Shipping Methods" +msgstr "" diff --git a/delivery_price_method/i18n/es.po b/delivery_price_method/i18n/es.po new file mode 100644 index 0000000000..9bf80d1cbb --- /dev/null +++ b/delivery_price_method/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * delivery_price_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-05-24 05:34+0000\n" +"Last-Translator: Leonardo J. Caballero G. \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__base_on_rule +msgid "Based on Rules" +msgstr "Basado en reglas" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__carrier +msgid "Carrier obtained price" +msgstr "Precio obtenido por el transportista" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__fixed +msgid "Fixed price" +msgstr "Precio fijo" + +#. module: delivery_price_method +#: model:ir.model.fields,field_description:delivery_price_method.field_delivery_carrier__price_method +msgid "Price method" +msgstr "Método de precio" + +#. module: delivery_price_method +#: model_terms:ir.ui.view,arch_db:delivery_price_method.view_delivery_carrier_form +msgid "Pricing" +msgstr "Precios" + +#. module: delivery_price_method +#: model:ir.model,name:delivery_price_method.model_delivery_carrier +msgid "Shipping Methods" +msgstr "Métodos de envío" diff --git a/delivery_price_method/i18n/es_CL.po b/delivery_price_method/i18n/es_CL.po new file mode 100644 index 0000000000..0fec900548 --- /dev/null +++ b/delivery_price_method/i18n/es_CL.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * delivery_price_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-05-24 05:34+0000\n" +"Last-Translator: Leonardo J. Caballero G. \n" +"Language-Team: none\n" +"Language: es_CL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__base_on_rule +msgid "Based on Rules" +msgstr "Basado en reglas" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__carrier +msgid "Carrier obtained price" +msgstr "Precio obtenido por el transportista" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__fixed +msgid "Fixed price" +msgstr "Precio fijo" + +#. module: delivery_price_method +#: model:ir.model.fields,field_description:delivery_price_method.field_delivery_carrier__price_method +msgid "Price method" +msgstr "Método de precio" + +#. module: delivery_price_method +#: model_terms:ir.ui.view,arch_db:delivery_price_method.view_delivery_carrier_form +msgid "Pricing" +msgstr "Precios" + +#. module: delivery_price_method +#: model:ir.model,name:delivery_price_method.model_delivery_carrier +msgid "Shipping Methods" +msgstr "Métodos de envío" diff --git a/delivery_price_method/i18n/es_VE.po b/delivery_price_method/i18n/es_VE.po new file mode 100644 index 0000000000..a588e1935b --- /dev/null +++ b/delivery_price_method/i18n/es_VE.po @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * delivery_price_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: es_VE\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__base_on_rule +msgid "Based on Rules" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__carrier +msgid "Carrier obtained price" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__fixed +msgid "Fixed price" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model.fields,field_description:delivery_price_method.field_delivery_carrier__price_method +msgid "Price method" +msgstr "" + +#. module: delivery_price_method +#: model_terms:ir.ui.view,arch_db:delivery_price_method.view_delivery_carrier_form +msgid "Pricing" +msgstr "" + +#. module: delivery_price_method +#: model:ir.model,name:delivery_price_method.model_delivery_carrier +msgid "Shipping Methods" +msgstr "" diff --git a/delivery_price_method/i18n/fr.po b/delivery_price_method/i18n/fr.po new file mode 100644 index 0000000000..cbee10dfae --- /dev/null +++ b/delivery_price_method/i18n/fr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * delivery_price_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-08 21:33+0000\n" +"Last-Translator: kbentaleb \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__base_on_rule +msgid "Based on Rules" +msgstr "Fondé sur des règles" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__carrier +msgid "Carrier obtained price" +msgstr "Prix transmis par le transporteur" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__fixed +msgid "Fixed price" +msgstr "Prix fixe" + +#. module: delivery_price_method +#: model:ir.model.fields,field_description:delivery_price_method.field_delivery_carrier__price_method +msgid "Price method" +msgstr "Mode de prix" + +#. module: delivery_price_method +#: model_terms:ir.ui.view,arch_db:delivery_price_method.view_delivery_carrier_form +msgid "Pricing" +msgstr "Prix" + +#. module: delivery_price_method +#: model:ir.model,name:delivery_price_method.model_delivery_carrier +msgid "Shipping Methods" +msgstr "Modes d'expédition" diff --git a/delivery_price_method/i18n/it.po b/delivery_price_method/i18n/it.po new file mode 100644 index 0000000000..55e69a3a58 --- /dev/null +++ b/delivery_price_method/i18n/it.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * delivery_price_method +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-05-08 07:42+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__base_on_rule +msgid "Based on Rules" +msgstr "In base alle regole" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__carrier +msgid "Carrier obtained price" +msgstr "Prezzo ottenuto dal vettore" + +#. module: delivery_price_method +#: model:ir.model.fields.selection,name:delivery_price_method.selection__delivery_carrier__price_method__fixed +msgid "Fixed price" +msgstr "Prezzo fisso" + +#. module: delivery_price_method +#: model:ir.model.fields,field_description:delivery_price_method.field_delivery_carrier__price_method +msgid "Price method" +msgstr "Metodo prezzo" + +#. module: delivery_price_method +#: model_terms:ir.ui.view,arch_db:delivery_price_method.view_delivery_carrier_form +msgid "Pricing" +msgstr "Definizione prezzi" + +#. module: delivery_price_method +#: model:ir.model,name:delivery_price_method.model_delivery_carrier +msgid "Shipping Methods" +msgstr "Metodi di spedizione" diff --git a/delivery_price_method/models/__init__.py b/delivery_price_method/models/__init__.py new file mode 100644 index 0000000000..c81a98c8ef --- /dev/null +++ b/delivery_price_method/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2020 Trey, Kilobytes de Soluciones +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import delivery_carrier diff --git a/delivery_price_method/models/delivery_carrier.py b/delivery_price_method/models/delivery_carrier.py new file mode 100644 index 0000000000..ebd8f993ae --- /dev/null +++ b/delivery_price_method/models/delivery_carrier.py @@ -0,0 +1,41 @@ +# Copyright 2020 Trey, Kilobytes de Soluciones +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class DeliveryCarrier(models.Model): + _inherit = "delivery.carrier" + + # pylint: disable=W8113 + price_method = fields.Selection( + selection=[ + ("carrier", "Carrier obtained price"), + ("fixed", "Fixed price"), + ("base_on_rule", "Based on Rules"), + ], + default="carrier", + string="Price method", + ) + + def rate_shipment(self, order): + """Trick the method for using all the upstream code for the + price computation in case of using fixed or base_on_rule. + """ + previous_method = False + if self.price_method in ("fixed", "base_on_rule"): + previous_method = self.delivery_type + self.sudo().delivery_type = self.price_method + res = super().rate_shipment(order) + if previous_method: + self.sudo().delivery_type = previous_method + return res + + def send_shipping(self, pickings): + res = super().send_shipping(pickings) + if self.price_method in ("fixed", "base_on_rule"): + rates = getattr(self, "%s_send_shipping" % self.price_method)(pickings) + for index, rate in enumerate(rates): + del rate["tracking_number"] # remove offending key + res[index].update(rate) + return res diff --git a/delivery_price_method/readme/CONTRIBUTORS.rst b/delivery_price_method/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f1c9a0bf5e --- /dev/null +++ b/delivery_price_method/readme/CONTRIBUTORS.rst @@ -0,0 +1,11 @@ +* `Trey `_: + + * Roberto Lizana + +* `Tecnativa `_: + + * Pedro M. Baeza + +* `QubiQ 2010 `_: + + * Marçal Isern diff --git a/delivery_price_method/readme/DESCRIPTION.rst b/delivery_price_method/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..f861433084 --- /dev/null +++ b/delivery_price_method/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module allows to force a local price rate computation for any delivery +method, including those that have been created to query a webservice for +fetching the rate. + +It uses the existing fixed price or price based on rules computations. diff --git a/delivery_price_method/readme/USAGE.rst b/delivery_price_method/readme/USAGE.rst new file mode 100644 index 0000000000..ce3592c365 --- /dev/null +++ b/delivery_price_method/readme/USAGE.rst @@ -0,0 +1,5 @@ +#. Go to *Sales > Configuration > Sales Orders > Delivery Methods*. +#. Open or create a new one. +#. On the "Price Method" field, select "Fixed Price" or "Based on Rules". +#. You will see standard fields for selecting the price as if the delivery + method isn't an integration carrier. diff --git a/delivery_price_method/static/description/icon.png b/delivery_price_method/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/delivery_price_method/static/description/icon.png differ diff --git a/delivery_price_method/static/description/index.html b/delivery_price_method/static/description/index.html new file mode 100644 index 0000000000..be9e8504da --- /dev/null +++ b/delivery_price_method/static/description/index.html @@ -0,0 +1,446 @@ + + + + + + +Delivery Price Method + + + +
+

Delivery Price Method

+ + +

Production/Stable License: AGPL-3 OCA/delivery-carrier Translate me on Weblate Try me on Runboat

+

This module allows to force a local price rate computation for any delivery +method, including those that have been created to query a webservice for +fetching the rate.

+

It uses the existing fixed price or price based on rules computations.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Sales > Configuration > Sales Orders > Delivery Methods.
  2. +
  3. Open or create a new one.
  4. +
  5. On the “Price Method” field, select “Fixed Price” or “Based on Rules”.
  6. +
  7. You will see standard fields for selecting the price as if the delivery +method isn’t an integration carrier.
  8. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Trey (www.trey.es)
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/delivery_price_method/tests/__init__.py b/delivery_price_method/tests/__init__.py new file mode 100644 index 0000000000..031e3d503c --- /dev/null +++ b/delivery_price_method/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2020 Trey, Kilobytes de Soluciones +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_delivery_price_method diff --git a/delivery_price_method/tests/test_delivery_price_method.py b/delivery_price_method/tests/test_delivery_price_method.py new file mode 100644 index 0000000000..542193127f --- /dev/null +++ b/delivery_price_method/tests/test_delivery_price_method.py @@ -0,0 +1,120 @@ +# Copyright 2020 Trey, Kilobytes de Soluciones +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import Form +from odoo.tests.common import TransactionCase +from odoo.tools import float_compare + + +class TestDeliveryPriceMethod(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + self = cls + product_shipping_cost = self.env["product.product"].create( + { + "type": "service", + "name": "Shipping costs", + "standard_price": 10, + "list_price": 100, + } + ) + self.carrier = self.env["delivery.carrier"].create( + { + "name": "Test carrier", + "delivery_type": "fixed", + "product_id": product_shipping_cost.id, + "fixed_price": 99.99, + } + ) + self.pricelist = self.env["product.pricelist"].create( + { + "name": "Test pricelist", + "item_ids": [ + ( + 0, + 0, + { + "applied_on": "3_global", + "compute_price": "formula", + "base": "list_price", + }, + ) + ], + } + ) + self.product = self.env.ref("product.product_delivery_01") + self.partner = self.env.ref("base.res_partner_12") + self.sale = self.env["sale.order"].create( + { + "partner_id": self.partner.id, + "pricelist_id": self.pricelist.id, + "carrier_id": self.carrier.id, + "order_line": [ + (0, 0, {"product_id": self.product.id, "product_uom_qty": 1}) + ], + } + ) + + def _add_delivery(self): + sale = self.sale + delivery_wizard = Form( + self.env["choose.delivery.carrier"].with_context( + default_order_id=sale.id, default_carrier_id=self.carrier + ) + ) + choose_delivery_carrier = delivery_wizard.save() + choose_delivery_carrier.button_confirm() + + def test_delivery_price_fixed(self): + sale = self.sale + self._add_delivery() + delivery_lines = sale.order_line.filtered(lambda r: r.is_delivery) + delivery_price = sum(delivery_lines.mapped("price_unit")) + self.assertEqual(float_compare(delivery_price, 99.99, precision_digits=2), 0) + self.assertEqual(len(delivery_lines), 1) + sale.action_confirm() + picking = sale.picking_ids[0] + picking.move_ids.quantity = 1 + self.assertEqual(len(picking.move_line_ids), 1) + self.assertEqual(picking.carrier_id, self.carrier) + picking.action_confirm() + picking.action_assign() + self.assertFalse(picking.carrier_price) + picking.send_to_shipper() + self.assertEqual(picking.carrier_price, 99.99) + + def test_delivery_price_method(self): + self.carrier.write({"price_method": "fixed", "fixed_price": 99.99}) + sale = self.sale + self._add_delivery() + delivery_lines = sale.order_line.filtered(lambda r: r.is_delivery) + delivery_price = sum(delivery_lines.mapped("price_unit")) + self.assertEqual(float_compare(delivery_price, 99.99, precision_digits=2), 0) + self.assertEqual(len(delivery_lines), 1) + self.carrier.write({"price_method": "fixed", "fixed_price": 5}) + self._add_delivery() + delivery_lines = sale.order_line.filtered(lambda r: r.is_delivery) + delivery_price = sum(delivery_lines.mapped("price_unit")) + self.assertEqual(delivery_price, 5) + self.carrier.write( + { + "price_method": "base_on_rule", + "price_rule_ids": [ + ( + 0, + 0, + { + "variable": "quantity", + "operator": "==", + "max_value": 1, + "list_base_price": 11.11, + }, + ) + ], + } + ) + self._add_delivery() + delivery_lines = sale.order_line.filtered(lambda r: r.is_delivery) + delivery_price = sum(delivery_lines.mapped("price_unit")) + self.assertEqual(delivery_price, 11.11) diff --git a/delivery_price_method/views/delivery_carrier_views.xml b/delivery_price_method/views/delivery_carrier_views.xml new file mode 100644 index 0000000000..ff956d649f --- /dev/null +++ b/delivery_price_method/views/delivery_carrier_views.xml @@ -0,0 +1,38 @@ + + + + + delivery.carrier + + + + + + + + + + + + + + + + + + + +