~david-cormier-j/sale-wkfl/sale_landed_costs

« back to all changes in this revision

Viewing changes to sale_cancel_reason/model/sale.py

  • Committer: Guewen Baconnier
  • Date: 2014-01-10 13:51:27 UTC
  • mfrom: (19.5.4 add-sale_cancel_reason-jge)
  • Revision ID: guewen.baconnier@camptocamp.com-20140110135127-665ppsgwppory0v4
[ADD] sale_cancel_reason: When a sale order is canceled, a reason must be given, it is chosen from a configured list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Author: Guewen Baconnier
 
5
#    Copyright 2013 Camptocamp SA
 
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
 
 
22
from openerp.osv import orm, fields
 
23
from openerp.tools.translate import _
 
24
 
 
25
 
 
26
class sale_order(orm.Model):
 
27
    _inherit = 'sale.order'
 
28
 
 
29
    _columns = {
 
30
        'cancel_reason_id': fields.many2one(
 
31
            'sale.order.cancel.reason',
 
32
            string="Reason for cancellation",
 
33
            readonly=True,
 
34
            ondelete="restrict"
 
35
        ),
 
36
    }
 
37
 
 
38
 
 
39
class sale_order_cancel_reason(orm.Model):
 
40
    _name = 'sale.order.cancel.reason'
 
41
    _description = 'Sale Order Cancel Reason'
 
42
    _columns = {
 
43
        'name': fields.char('Reason', required=True, translate=True),
 
44
    }