[IMP] purchase: rename config wizard to 'purchase.config.settings'
[odoo/odoo.git] / addons / purchase / res_config.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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 osv import fields, osv
23 import pooler
24 from tools.translate import _
25
26 class purchase_config_settings(osv.osv_memory):
27     _name = 'purchase.config.settings'
28     _inherit = 'res.config.settings'
29
30     _columns = {
31         'default_invoice_method': fields.selection(
32             [('manual', 'Based on Purchase Order Lines'),
33              ('picking', 'Based on Receptions'),
34              ('order', 'Pre-Generate Draft Invoices based on Purchase Orders'),
35             ], 'Invoicing Method', required=True, default_model='purchase.order'),
36         'module_purchase_analytic_plans': fields.boolean('Purchase analytic plan',
37             help ="""Allows the user to maintain several analysis plans. These let you split
38                 lines on a purchase order between several accounts and analytic plans.
39                 This installs the module purchase_analytic_plans."""),
40         'module_warning': fields.boolean("Alerts by products or supplier",
41             help="""To trigger warnings in OpenERP objects.
42                 Warning messages can be displayed for objects like sale order, purchase order, picking and invoice.
43                 This installs the module warning."""),
44         'module_product_manufacturer': fields.boolean("Define a manufacturer of products",
45             help="""This allows you to define the following for a product:
46                     * Manufacturer
47                     * Manufacturer Product Name
48                     * Manufacturer Product Code
49                     * Product Attributes.
50                 This installs the module product_manufacturer."""),
51         'module_purchase_double_validation': fields.boolean("Configure limit amount",
52             help="""Provide a double validation mechanism for purchases exceeding minimum amount.
53                 This installs the module purchase_double_validation."""),
54         'module_purchase_requisition': fields.boolean("Track the best price with Purchase Requisition",
55             help="""When a purchase order is created, you have the opportunity to save the related requisition.
56                 This object regroups and allows you to keep track and order all your purchase orders.
57                 This installs the module purchase_requisition."""),
58         'tax_policy': fields.selection(
59             [('no_tax', 'No Tax'), ('global_on_order', 'Global On Order'), ('on_order_line', 'On Order Lines')],
60             'Taxes', required=True,
61             help="""Choose between either applying global taxes on a purchase order, or applying different taxes on purchase order lines, or applying no tax at all."""),
62         'group_purchase_taxes_global_on_order':fields.boolean("Global on order",
63             implied_group='base.group_purchase_taxes_global_on_order'),
64         'group_purchase_taxes_on_order_line':fields.boolean("On order line",
65             implied_group='base.group_purchase_taxes_on_order_line'),
66     }
67
68     def default_get(self, cr, uid, fields, context=None):
69         res = super(purchase_config_settings, self).default_get(cr, uid, fields, context)
70         res['tax_policy'] = \
71             (res.get('group_purchase_taxes_global_on_order') and 'global_on_order') or \
72             (res.get('group_purchase_taxes_on_order_line') and 'on_order_line') or \
73             'no_tax'
74         return res
75
76     _defaults = {
77         'tax_policy': 'global_on_order',
78     }
79
80     def onchange_tax_policy(self, cr, uid, ids, tax_policy, context=None):
81         return {'value': {
82             'group_purchase_taxes_global_on_order': tax_policy == 'global_on_order',
83             'group_purchase_taxes_on_order_line': tax_policy == 'on_order_line',
84         }}
85
86 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: