Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] delivery_product_restriction: migration to 16.0 #333

Open
wants to merge 15 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
81 changes: 81 additions & 0 deletions delivery_product_restriction/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
============================
Delivery Product Restriction
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:6560f777eb61a664995e54c8ce1532eacf60f2c307b58c38308383117f9b70ab
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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-coopiteasy%2Faddons-lightgray.png?logo=github
:target: https://github.com/coopiteasy/addons/tree/16.0/delivery_product_restriction
:alt: coopiteasy/addons

|badge1| |badge2| |badge3|

It allows some product to be shipped only by some delivery carrier. If
such a product is found in a SO then the SO can only be shipped via
these delivery carrier.

To get this features works in the eCommerce install the
`website_sale_delivery_product_restriction` module.

**Table of contents**

.. contents::
:local:

Usage
=====

Find the product that can only be shipped with a restricted list of
delivery carrier. Then:

#. Open the *Sale* tab of the product.
#. In the *Delivey Options* section, edit the **Restrict Delivery
Carrier To**, and add the delivery carrier accepted for this product.

Now, when you create an order with this product, the available delivery
carrier will be restricted to the one that you specified if other
condition of the specified delivery are ok.

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

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/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 <https://github.com/coopiteasy/addons/issues/new?body=module:%20delivery_product_restriction%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SC

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Rémy Taymans

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/16.0/delivery_product_restriction>`_ project on GitHub.

You are welcome to contribute.
2 changes: 2 additions & 0 deletions delivery_product_restriction/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
21 changes: 21 additions & 0 deletions delivery_product_restriction/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022 Coop IT Easy SC
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Delivery Product Restriction",
"summary": """
Allow some product to be shipped only by some delivery carrier.""",
"version": "16.0.1.0.0",
"category": "Delivery",
"website": "https://github.com/coopiteasy/addons",
"author": "Coop IT Easy SC",
"license": "AGPL-3",
"application": False,
"depends": ["sale", "delivery"],
"excludes": [],
"data": [
"views/product_template.xml",
],
"demo": [],
"qweb": [],
}
47 changes: 47 additions & 0 deletions delivery_product_restriction/i18n/delivery_product_restriction.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * delivery_product_restriction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.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_product_restriction
#: model:ir.model,name:delivery_product_restriction.model_delivery_carrier
msgid "Delivery Methods"
msgstr ""

#. module: delivery_product_restriction
#: model_terms:ir.ui.view,arch_db:delivery_product_restriction.product_template_form_view
msgid "Delivery Options"
msgstr ""

#. module: delivery_product_restriction
#: model:ir.model,name:delivery_product_restriction.model_product_template
msgid "Product Template"
msgstr ""

#. module: delivery_product_restriction
#: model:ir.model.fields,field_description:delivery_product_restriction.field_product_product__restrict_delivery_carrier_to
#: model:ir.model.fields,field_description:delivery_product_restriction.field_product_template__restrict_delivery_carrier_to
msgid "Restrict Delivery Carrier To"
msgstr ""

#. module: delivery_product_restriction
#: model:ir.model,name:delivery_product_restriction.model_sale_order
msgid "Sale Order"
msgstr ""

#. module: delivery_product_restriction
#: model:ir.model.fields,help:delivery_product_restriction.field_product_product__restrict_delivery_carrier_to
#: model:ir.model.fields,help:delivery_product_restriction.field_product_template__restrict_delivery_carrier_to
msgid "This product can only be shipped with the following delivery carrier. Left empty to allow all delivery carrier to be used."
msgstr ""

2 changes: 2 additions & 0 deletions delivery_product_restriction/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import delivery_carrier
from . import product_template
33 changes: 33 additions & 0 deletions delivery_product_restriction/models/delivery_carrier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2022 Coop IT Easy SC
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class DeliveryCarrier(models.Model):

_inherit = "delivery.carrier"

def _can_be_used_to_deliver_products(self, products):
self.ensure_one()
return all(
not product.restrict_delivery_carrier_to
or self in product.restrict_delivery_carrier_to
for product in products
)

def available_carriers(self, partner, products=None):
"""
Override the `available_carriers` function in the
delivery.carrier in the delivery module.

Returns a recordset of the available delivery carrier given the
partner location and the authorised carrier for the products.
"""
# the default behavior is to filter by the address of the partner.
delivery_carriers = super().available_carriers(partner)
if products:
delivery_carriers = delivery_carriers.filtered(
lambda c: c._can_be_used_to_deliver_products(products)
)
return delivery_carriers
16 changes: 16 additions & 0 deletions delivery_product_restriction/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 Coop IT Easy SC
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductTemplate(models.Model):

_inherit = "product.template"

restrict_delivery_carrier_to = fields.Many2many(
comodel_name="delivery.carrier",
help="This product can only be shipped with the following "
"delivery carrier. Left empty to allow all delivery carrier to "
"be used.",
)
3 changes: 3 additions & 0 deletions delivery_product_restriction/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Rémy Taymans
6 changes: 6 additions & 0 deletions delivery_product_restriction/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
It allows some product to be shipped only by some delivery carrier. If
such a product is found in a SO then the SO can only be shipped via
these delivery carrier.

To get this features works in the eCommerce install the
`website_sale_delivery_product_restriction` module.
10 changes: 10 additions & 0 deletions delivery_product_restriction/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Find the product that can only be shipped with a restricted list of
delivery carrier. Then:

#. Open the *Sale* tab of the product.
#. In the *Delivey Options* section, edit the **Restrict Delivery
Carrier To**, and add the delivery carrier accepted for this product.

Now, when you create an order with this product, the available delivery
carrier will be restricted to the one that you specified if other
condition of the specified delivery are ok.
Loading
Loading