[IMP] purchase: misc usability improvements
[odoo/odoo.git] / addons / purchase / res_config.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Business Applications
5 #    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.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
22 from openerp.osv import fields, osv
23 from openerp.tools.translate import _
24
25 class purchase_config_settings(osv.osv_memory):
26     _name = 'purchase.config.settings'
27     _inherit = 'res.config.settings'
28
29     _columns = {
30         'default_invoice_method': fields.selection(
31             [('manual', 'Based on purchase order lines'),
32              ('picking', 'Based on incoming shipments'),
33              ('order', 'Pre-generate draft invoices based on purchase orders'),
34             ], 'Default invoicing control method', required=True, default_model='purchase.order'),
35         'group_purchase_pricelist':fields.boolean("Manage pricelist per supplier",
36             implied_group='product.group_purchase_pricelist',
37             help='Allows to manage different prices based on rules per category of Supplier.\n'
38                  'Example: 10% for retailers, promotion of 5 EUR on this product, etc.'),
39         'group_uom':fields.boolean("Manage different units of measure for products",
40             implied_group='product.group_uom',
41             help="""Allows you to select and maintain different units of measure for products."""),
42         'group_costing_method':fields.boolean("Use 'Real Price' or 'Average' costing methods.",
43             implied_group='stock_account.group_inventory_valuation',
44             help="""Allows you to compute product cost price based on average cost."""),
45         'module_warning': fields.boolean("Alerts by products or supplier",
46             help='Allow to configure notification on products and trigger them when a user wants to purchase a given product or a given supplier.\n'
47                  'Example: Product: this product is deprecated, do not purchase more than 5.\n'
48                  'Supplier: don\'t forget to ask for an express delivery.'),
49         'module_purchase_double_validation': fields.boolean("Force two levels of approvals",
50             help='Provide a double validation mechanism for purchases exceeding minimum amount.\n'
51                  '-This installs the module purchase_double_validation.'),
52         'module_purchase_requisition': fields.boolean("Manage calls for bids",
53             help="""Calls for bids are used when you want to generate requests for quotations to several suppliers for a given set of products.
54             You can configure per product if you directly do a Request for Quotation
55             to one supplier or if you want a Call for Bids to compare offers from several suppliers."""),
56         'group_advance_purchase_requisition': fields.boolean("Choose from several bids in a call for bids",
57             implied_group='purchase.group_advance_bidding',
58             help="""In the process of a public bidding, you can compare the bid lines and choose for each requested product from which bid you
59             buy which quantity"""),
60         'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on purchase orders',
61             help='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
62                  '-This installs the module purchase_analytic_plans.'),
63         'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
64             implied_group='purchase.group_analytic_accounting',
65             help="Allows you to specify an analytic account on purchase order lines."),
66         'module_stock_dropshipping': fields.boolean("Manage dropshipping",
67             help='\nCreates the dropship route and add more complex tests'
68                  '-This installs the module stock_dropshipping.'),
69     }
70
71     _defaults = {
72         'default_invoice_method': 'order',
73     }
74
75     def onchange_purchase_analytic_plans(self, cr, uid, ids, module_purchase_analytic_plans, context=None):
76         """ change group_analytic_account_for_purchases following module_purchase_analytic_plans """
77         if not module_purchase_analytic_plans:
78             return {}
79         return {'value': {'group_analytic_account_for_purchases': module_purchase_analytic_plans}}
80
81
82
83 class account_config_settings(osv.osv_memory):
84     _inherit = 'account.config.settings'
85     _columns = {
86         'module_purchase_analytic_plans': fields.boolean('Use multiple analytic accounts on orders',
87             help='Allows the user to maintain several analysis plans. These let you split lines on a purchase order between several accounts and analytic plans.\n'
88                  '-This installs the module purchase_analytic_plans.'),
89         'group_analytic_account_for_purchases': fields.boolean('Analytic accounting for purchases',
90             implied_group='purchase.group_analytic_accounting',
91             help="Allows you to specify an analytic account on purchase order lines."),
92     }
93
94     def onchange_purchase_analytic_plans(self, cr, uid, ids, module_purchase_analytic_plans, context=None):
95         """ change group_analytic_account_for_purchases following module_purchase_analytic_plans """
96         if not module_purchase_analytic_plans:
97             return {}
98         return {'value': {'group_analytic_account_for_purchases': module_purchase_analytic_plans}}
99
100 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: