Skip to content

Commit 906b0c1

Browse files
committed
Merge PR #900 into 18.0
Signed-off-by hparfr
2 parents 3b9dba7 + 61e7b68 commit 906b0c1

20 files changed

+898
-0
lines changed

delivery_carrier_option/README.rst

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
=======================
2+
Delivery Carrier Option
3+
=======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:ec863ea454ac78b21548aad2e7786daaad02075270d3d13ae43c8fb16b89a56c
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github
20+
:target: https://github.com/OCA/delivery-carrier/tree/18.0/delivery_carrier_option
21+
:alt: OCA/delivery-carrier
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/delivery-carrier-18-0/delivery-carrier-18-0-delivery_carrier_option
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/delivery-carrier&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds the concept of option on carriers that can differ
32+
depending on the picking This module doesn't do anything by itself, it
33+
serves as a base module for other carrier-specific modules.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Bug Tracker
41+
===========
42+
43+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_.
44+
In case of trouble, please check there if your issue has already been reported.
45+
If you spotted it first, help us to smash it by providing a detailed and welcomed
46+
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_carrier_option%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
47+
48+
Do not contact contributors directly about support or help with technical issues.
49+
50+
Credits
51+
=======
52+
53+
Authors
54+
-------
55+
56+
* Camptocamp
57+
* Akretion
58+
59+
Contributors
60+
------------
61+
62+
- David BEAL <david.beal@akretion.com>
63+
- Sébastien BEAU <sebastien.beau@akretion.com>
64+
- Yannick Vaucher <yannick.vaucher@camptocamp.com>
65+
- Alexis de Lattre <alexis.delattre@akretion.com>
66+
- Angel Moya <angel.moya@pesol.es>
67+
- Ismael Calvo <ismael.calvo@factorlibre.com>
68+
- Dave Lasley <dave@laslabs.com>
69+
- Timothée Ringeard <timothee.ringeard@camptocamp.com>
70+
- Pimolnat Suntian <pimolnats@ecosoft.co.th>
71+
- Raphaël Reverdy <raphael.reverdy@akretion.com>
72+
73+
Maintainers
74+
-----------
75+
76+
This module is maintained by the OCA.
77+
78+
.. image:: https://odoo-community.org/logo.png
79+
:alt: Odoo Community Association
80+
:target: https://odoo-community.org
81+
82+
OCA, or the Odoo Community Association, is a nonprofit organization whose
83+
mission is to support the collaborative development of Odoo features and
84+
promote its widespread use.
85+
86+
.. |maintainer-florian-dacosta| image:: https://github.com/florian-dacosta.png?size=40px
87+
:target: https://github.com/florian-dacosta
88+
:alt: florian-dacosta
89+
90+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
91+
92+
|maintainer-florian-dacosta|
93+
94+
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/18.0/delivery_carrier_option>`_ project on GitHub.
95+
96+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

delivery_carrier_option/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
2+
{
3+
"name": "Delivery Carrier Option",
4+
"version": "18.0.1.0.0",
5+
"author": "Camptocamp,Akretion,Odoo Community Association (OCA)",
6+
"category": "Delivery",
7+
"maintainers": ["florian-dacosta"],
8+
"depends": [
9+
"stock_delivery",
10+
],
11+
"website": "https://github.com/OCA/delivery-carrier",
12+
"data": [
13+
"views/stock_picking.xml",
14+
"views/delivery_carrier.xml",
15+
"security/ir.model.access.csv",
16+
"views/delivery_carrier_template_option.xml",
17+
"views/delivery_carrier_option.xml",
18+
],
19+
"installable": True,
20+
"license": "AGPL-3",
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from . import delivery_carrier
2+
from . import delivery_carrier_template_option
3+
from . import delivery_carrier_option
4+
from . import stock_picking
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2012 Akretion <http://www.akretion.com>.
2+
# Copyright 2013-2016 Camptocamp SA
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import fields, models
6+
7+
8+
class DeliveryCarrier(models.Model):
9+
_inherit = "delivery.carrier"
10+
11+
available_option_ids = fields.One2many(
12+
comodel_name="delivery.carrier.option",
13+
inverse_name="carrier_id",
14+
string="Option",
15+
context={"active_test": False},
16+
)
17+
18+
def default_options(self):
19+
"""Returns default and available options for a carrier"""
20+
self.ensure_one()
21+
options = self.env["delivery.carrier.option"].browse()
22+
for available_option in self.available_option_ids:
23+
if available_option.mandatory or available_option.by_default:
24+
options |= available_option
25+
return options
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright 2012 Akretion <http://www.akretion.com>.
2+
# Copyright 2013-2016 Camptocamp SA
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import api, fields, models
6+
7+
8+
class DeliveryCarrierOption(models.Model):
9+
"""Option selected for a carrier method
10+
11+
Those options define the list of available pre-added and available
12+
to be added on delivery orders
13+
14+
"""
15+
16+
_name = "delivery.carrier.option"
17+
_description = "Delivery carrier option"
18+
_inherits = {"delivery.carrier.template.option": "tmpl_option_id"}
19+
20+
active = fields.Boolean(default=True)
21+
mandatory = fields.Boolean(
22+
help=(
23+
"If checked, this option is necessarily applied "
24+
"to the delivery order. Mandatory options show up in orange "
25+
"in the option widget on the picking."
26+
),
27+
)
28+
by_default = fields.Boolean(
29+
string="Applied by Default",
30+
help="By check, user can choose to apply this option "
31+
"to each Delivery Order\n using this delivery method",
32+
)
33+
tmpl_option_id = fields.Many2one(
34+
comodel_name="delivery.carrier.template.option",
35+
string="Option",
36+
required=True,
37+
ondelete="cascade",
38+
)
39+
carrier_id = fields.Many2one(comodel_name="delivery.carrier")
40+
readonly_flag = fields.Boolean(
41+
help="When True, help to prevent the user to modify some fields "
42+
"option (if attribute is defined in the view)",
43+
)
44+
color = fields.Integer(
45+
compute="_compute_color",
46+
help="Orange if the option is mandatory, otherwise no color",
47+
)
48+
49+
@api.depends("mandatory")
50+
def _compute_color(self):
51+
"""Show that a tag is mandatory using the color attribute"""
52+
for tag in self:
53+
tag.color = 2 if tag.mandatory else False
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2012 Akretion <http://www.akretion.com>.
2+
# Copyright 2013-2016 Camptocamp SA
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import fields, models
6+
7+
8+
class DeliveryCarrierTemplateOption(models.Model):
9+
"""Available options for a carrier (partner)"""
10+
11+
_name = "delivery.carrier.template.option"
12+
_description = "Delivery carrier template option"
13+
14+
type = fields.Selection(
15+
selection=[
16+
("basic", "Basic Service"),
17+
("additional", "Additional Service"),
18+
("delivery", "Delivery Instructions"),
19+
("partner_option", "Partner Option"),
20+
],
21+
default="basic",
22+
string="Option Type",
23+
)
24+
partner_id = fields.Many2one(comodel_name="res.partner", string="Partner Carrier")
25+
name = fields.Char()
26+
code = fields.Char()
27+
description = fields.Char(
28+
help="Allow to define a more complete description " "than in the name field.",
29+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2012-2015 Akretion <http://www.akretion.com>.
2+
# Copyright 2013-2016 Camptocamp SA
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
import logging
6+
7+
from odoo import api, fields, models
8+
9+
_logger = logging.getLogger(__name__)
10+
11+
12+
class StockPicking(models.Model):
13+
_inherit = "stock.picking"
14+
15+
option_ids = fields.Many2many(
16+
comodel_name="delivery.carrier.option",
17+
string="Options",
18+
compute="_compute_option_ids",
19+
store=True,
20+
readonly=False,
21+
)
22+
23+
@api.depends("carrier_id")
24+
def _compute_option_ids(self):
25+
for picking in self:
26+
picking.option_ids = picking._get_default_options()
27+
28+
def _get_default_options(self):
29+
self.ensure_one()
30+
default_options = []
31+
if self.carrier_id:
32+
default_options = self.carrier_id.default_options()
33+
return default_options
34+
35+
@api.onchange("option_ids")
36+
def onchange_option_ids(self):
37+
if not self.carrier_id:
38+
return
39+
carrier = self.carrier_id
40+
current_options = options = self.option_ids
41+
for available_option in carrier.available_option_ids:
42+
if (
43+
available_option.mandatory
44+
and available_option.id not in self.option_ids.ids
45+
):
46+
options |= available_option
47+
if current_options != options:
48+
self.option_ids = options
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- David BEAL \<<david.beal@akretion.com>\>
2+
- Sébastien BEAU \<<sebastien.beau@akretion.com>\>
3+
- Yannick Vaucher \<<yannick.vaucher@camptocamp.com>\>
4+
- Alexis de Lattre \<<alexis.delattre@akretion.com>\>
5+
- Angel Moya \<<angel.moya@pesol.es>\>
6+
- Ismael Calvo \<<ismael.calvo@factorlibre.com>\>
7+
- Dave Lasley \<<dave@laslabs.com>\>
8+
- Timothée Ringeard \<<timothee.ringeard@camptocamp.com>\>
9+
- Pimolnat Suntian \<<pimolnats@ecosoft.co.th>\>
10+
- Raphaël Reverdy \<<raphael.reverdy@akretion.com>\>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This module adds the concept of option on carriers that can differ
2+
depending on the picking This module doesn't do anything by itself, it
3+
serves as a base module for other carrier-specific modules.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_delivery_carrier_option_salesman,delivery.carrier.option.salesman,model_delivery_carrier_option,sales_team.group_sale_salesman,1,0,0,0
3+
access_delivery_carrier_option_sale_manager,delivery.carrier.option.sale.manager,model_delivery_carrier_option,sales_team.group_sale_manager,1,1,1,1
4+
access_delivery_carrier_template_option_salesman,delivery.carrier.relation.option.salesman,model_delivery_carrier_template_option,sales_team.group_sale_salesman,1,0,0,0
5+
access_delivery_carrier_template_option_sales_manager,delivery.carrier.relation.option.sale.manager,model_delivery_carrier_template_option,sales_team.group_sale_manager,1,1,1,1
6+
access_delivery_carrier_option_stock_user,delivery.carrier.option stock_user,model_delivery_carrier_option,stock.group_stock_user,1,1,1,1
7+
access_delivery_carrier_template_option_stock_user,delivery.carrier.template.option stock_user,model_delivery_carrier_template_option,stock.group_stock_user,1,0,0,0
8+
access_delivery_carrier_template_option_stock_manager,delivery.carrier.template.option stock_manager,model_delivery_carrier_template_option,stock.group_stock_manager,1,1,1,1
Loading

0 commit comments

Comments
 (0)