Skip to content

Commit

Permalink
[14.0][ADD] delivery_carrier_typology
Browse files Browse the repository at this point in the history
  • Loading branch information
chafique-delli committed Oct 3, 2023
1 parent c0454eb commit 9d4bb58
Show file tree
Hide file tree
Showing 19 changed files with 887 additions and 0 deletions.
79 changes: 79 additions & 0 deletions delivery_carrier_typology/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
=========================
Delivery Carrier typology
=========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-OCA%2Fdelivery--carrier-lightgray.png?logo=github
:target: https://github.com/OCA/delivery-carrier/tree/14.0/delivery_carrier_typology
: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-14-0/delivery-carrier-14-0-delivery_carrier_typology
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/99/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows:
- to specify the different means of transport used by a carrier (eg air freight, sea freight, etc.)
- to specify on a product, the means of transport which are prohibited (eg air freight for dangerous products)
- to select only delivery carriers via means of transport that are not prohibited for products in a sale order.


**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_carrier_typology%0Aversion:%2014.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
~~~~~~~

* Akretion

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

* `Akretion <https://www.akretion.com>`_

* Chafique Delli <[email protected]>

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 <https://github.com/OCA/delivery-carrier/tree/14.0/delivery_carrier_typology>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions delivery_carrier_typology/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions delivery_carrier_typology/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Delivery Carrier Typology",
"version": "14.0.1.0.0",
"category": "Delivery",
"website": "https://github.com/OCA/delivery-carrier",
"author": "Akretion, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"delivery",
],
"data": [
"security/ir.model.access.csv",
"views/delivery_carrier.xml",
"views/product.xml",
],
"installable": True,
}
117 changes: 117 additions & 0 deletions delivery_carrier_typology/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * delivery_carrier_typology
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-04 13:52+0000\n"
"PO-Revision-Date: 2023-09-04 13:52+0000\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_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__company_id
msgid "Company"
msgstr "Société"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__create_uid
msgid "Created by"
msgstr "Créé par"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__create_date
msgid "Created on"
msgstr "Créé le"

#. module: delivery_carrier_typology
#: model_terms:ir.actions.act_window,help:delivery_carrier_typology.action_delivery_carrier_typology_form
msgid "Define new shipping means"
msgstr "Créez un nouveau moyen de transport"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__description
msgid "Description"
msgstr "Description"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier__display_name
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__display_name
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_product_template__display_name
msgid "Display Name"
msgstr "Nom affiché"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier__id
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__id
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_product_template__id
msgid "ID"
msgstr "ID"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier____last_update
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology____last_update
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_product_template____last_update
msgid "Last Modified on"
msgstr "Dernière modification le"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour faite par"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"

#. module: delivery_carrier_typology
#: model:ir.model,name:delivery_carrier_typology.model_delivery_carrier_typology
#: model_terms:ir.ui.view,arch_db:delivery_carrier_typology.view_delivery_carrier_typology_form
#: model_terms:ir.ui.view,arch_db:delivery_carrier_typology.view_delivery_carrier_typology_tree
msgid "Shipping means"
msgstr "Moyens de transport"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier__shipping_means_id
msgid "Shipping means"
msgstr "Moyens de transport"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_delivery_carrier_typology__name
#: model_terms:ir.ui.view,arch_db:delivery_carrier_typology.view_delivery_carrier_typology_form
msgid "Name"
msgstr "Nom"

#. module: delivery_carrier_typology
#: model:ir.model,name:delivery_carrier_typology.model_product_template
msgid "Product Template"
msgstr "Modèle d'article"

#. module: delivery_carrier_typology
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_product_product__prohibited_shipping_means_ids
#: model:ir.model.fields,field_description:delivery_carrier_typology.field_product_template__prohibited_shipping_means_ids
msgid "Prohibited shipping means"
msgstr "Moyens de transport interdits"

#. module: delivery_carrier_typology
#: model:ir.actions.act_window,name:delivery_carrier_typology.action_delivery_carrier_typology_form
#: model:ir.ui.menu,name:delivery_carrier_typology.menu_action_delivery_carrier_typology_form
msgid "Shipping Means"
msgstr "Moyens de transport"

#. module: delivery_carrier_typology
#: model:ir.model,name:delivery_carrier_typology.model_delivery_carrier
msgid "Shipping Methods"
msgstr "Méthodes d'expédition"

#. module: delivery_carrier_typology
#: model_terms:ir.ui.view,arch_db:delivery_carrier_typology.view_delivery_carrier_typology_form
msgid "e.g. Air freight"
msgstr "ex. Frêt aérien"
3 changes: 3 additions & 0 deletions delivery_carrier_typology/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import delivery_carrier
from . import product
from . import sale_order_line
38 changes: 38 additions & 0 deletions delivery_carrier_typology/models/delivery_carrier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class DeliveryCarrier(models.Model):
_inherit = "delivery.carrier"

shipping_means_ids = fields.Many2many(
comodel_name="delivery.carrier.typology",
string="Shipping means",
)

def available_carriers(self, partner):
res = super().available_carriers(partner)
if self.env.context.get("active_model") == "sale.order":
sale = self.env["sale.order"].browse(self.env.context.get("active_id"))
prohibited_shipping_means_ids = sale.order_line.mapped(
"prohibited_shipping_means_ids"
)
new_res = self.browse()
for carrier in res:
if not set(carrier.shipping_means_ids) & set(
prohibited_shipping_means_ids
):
new_res += carrier
res = new_res
return res


class DeliveryCarrierTypology(models.Model):
_name = "delivery.carrier.typology"
_description = "Shipping means"

name = fields.Char(string="Name", required=True, translate=True)
description = fields.Char(string="Description", translate=True)
company_id = fields.Many2one("res.company", string="Company")
13 changes: 13 additions & 0 deletions delivery_carrier_typology/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

prohibited_shipping_means_ids = fields.Many2many(
"delivery.carrier.typology",
string="Prohibited shipping means",
)
12 changes: 12 additions & 0 deletions delivery_carrier_typology/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleOrderLine(models.Model):
_inherit = "sale.order.line"

prohibited_shipping_means_ids = fields.Many2many(
"delivery.carrier.typology", related="product_id.prohibited_shipping_means_ids"
)
3 changes: 3 additions & 0 deletions delivery_carrier_typology/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Akretion <https://www.akretion.com>`_

* Chafique Delli <[email protected]>
4 changes: 4 additions & 0 deletions delivery_carrier_typology/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module allows:
- to specify the different means of transport used by a carrier (eg air freight, sea freight, etc.).
- to specify on a product, the means of transport which are prohibited (eg air freight for dangerous products).
- to select only delivery carriers via means of transport that are not prohibited for products in a sale order.
4 changes: 4 additions & 0 deletions delivery_carrier_typology/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_delivery_carrier_typology,delivery.carrier.typology,model_delivery_carrier_typology,sales_team.group_sale_salesman,1,0,0,0
access_delivery_carrier_typology_stock,delivery.carrier.typology.stock,model_delivery_carrier_typology,stock.group_stock_user,1,0,0,0
access_delivery_carrier_typology_stock_manager,delivery.carrier.typology.stock.manager,model_delivery_carrier_typology,stock.group_stock_manager,1,1,1,1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9d4bb58

Please sign in to comment.