1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Author: Sébastien BEAU <sebastien.beau@akretion.com>
5
# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>.
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as
9
# published by the Free Software Foundation, either version 3 of the
10
# License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Affero General Public License for more details.
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
21
from openerp.osv import orm, fields
24
class DeliveryCarrierTemplateOption(orm.Model):
25
""" Available options for a carrier (partner) """
26
_name = 'delivery.carrier.template.option'
27
_description = 'Delivery carrier template option'
30
'partner_id': fields.many2one('res.partner', 'Partner Carrier'),
31
'name': fields.char('Name', size=64),
32
'code': fields.char('Code', size=64),
36
class DeliveryCarrierOption(orm.Model):
37
""" Option selected for a carrier method
39
Those options define the list of available pre-added and available
40
to be added on delivery orders
43
_name = 'delivery.carrier.option'
44
_description = 'Delivery carrier option'
45
_inherits = {'delivery.carrier.template.option': 'tmpl_option_id'}
48
'state': fields.selection(
49
(('mandatory', 'Mandatory'),
50
('default_option', 'Optional by Default'),
51
('option', 'Optional'),
53
string='Option Configuration',
54
help="Ensure you add and define correctly all your options or those won't "
55
"be available for the packager\n"
56
"- Mandatory: This option will be copied on carrier and cannot be removed\n"
57
"- Optional by Default: This option will be copied but can be removed\n"
58
"- Optional: This option can be added later by the user on the Delivery Order."),
59
'tmpl_option_id': fields.many2one(
60
'delivery.carrier.template.option',
61
string='Option', required=True, ondelete="cascade"),
62
'carrier_id': fields.many2one('delivery.carrier', 'Carrier'),
66
class DeliveryCarrier(orm.Model):
67
_inherit = 'delivery.carrier'
69
def _get_carrier_type_selection(self, cr, uid, context=None):
70
""" To inherit to add carrier type """
74
'type': fields.selection(
75
_get_carrier_type_selection, 'Type',
76
help="Carrier type (combines several delivery methods)"),
79
help="Delivery Method Code (according to carrier)"),
80
'description': fields.text('Description'),
81
'available_option_ids': fields.one2many(
82
'delivery.carrier.option',
83
'carrier_id', 'Option'),