~stock-logistic-core-editors/carriers-deliveries/github-7.0

« back to all changes in this revision

Viewing changes to base_delivery_carrier_label/delivery.py

  • Committer: Joel Grand-Guillaume
  • Author(s): Yannick Vaucher
  • Date: 2014-01-17 15:32:57 UTC
  • mfrom: (7.1.22)
  • Revision ID: git-v1:0748467ab0e1873d434e8b30dc0e871af2d4e659
[MRG][MIGR] Port of delivery_base and deliver_shipping_label removing direct print logic

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Author: Sébastien BEAU <sebastien.beau@akretion.com>
 
5
#    Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>.
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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/>.
 
19
#
 
20
##############################################################################
 
21
from openerp.osv import orm, fields
 
22
 
 
23
 
 
24
class DeliveryCarrierTemplateOption(orm.Model):
 
25
    """ Available options for a carrier (partner) """
 
26
    _name = 'delivery.carrier.template.option'
 
27
    _description = 'Delivery carrier template option'
 
28
 
 
29
    _columns = {
 
30
        'partner_id': fields.many2one('res.partner', 'Partner Carrier'),
 
31
        'name': fields.char('Name', size=64),
 
32
        'code': fields.char('Code', size=64),
 
33
    }
 
34
 
 
35
 
 
36
class DeliveryCarrierOption(orm.Model):
 
37
    """ Option selected for a carrier method
 
38
 
 
39
    Those options define the list of available pre-added and available
 
40
    to be added on delivery orders
 
41
 
 
42
    """
 
43
    _name = 'delivery.carrier.option'
 
44
    _description = 'Delivery carrier option'
 
45
    _inherits = {'delivery.carrier.template.option': 'tmpl_option_id'}
 
46
 
 
47
    _columns = {
 
48
        'state': fields.selection(
 
49
            (('mandatory', 'Mandatory'),
 
50
             ('default_option', 'Optional by Default'),
 
51
             ('option', 'Optional'),
 
52
             ),
 
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'),
 
63
    }
 
64
 
 
65
 
 
66
class DeliveryCarrier(orm.Model):
 
67
    _inherit = 'delivery.carrier'
 
68
 
 
69
    def _get_carrier_type_selection(self, cr, uid, context=None):
 
70
        """ To inherit to add carrier type """
 
71
        return []
 
72
 
 
73
    _columns = {
 
74
        'type': fields.selection(
 
75
            _get_carrier_type_selection, 'Type',
 
76
            help="Carrier type (combines several delivery methods)"),
 
77
        'code': fields.char(
 
78
            'Code', size=10,
 
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'),
 
84
    }