1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Business Applications
5 # Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.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 ##############################################################################
22 from osv import fields, osv
24 from tools.translate import _
26 class purchase_config_settings(osv.osv_memory):
27 _name = 'purchase.config.settings'
28 _inherit = 'res.config.settings'
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 ], 'Default Invoicing Control Method', required=True, default_model='purchase.order'),
36 'group_purchase_pricelist':fields.boolean("Pricelist per Supplier",
37 implied_group='product.group_purchase_pricelist',
38 help="""Allows to manage different prices based on rules per category of Supplier.
39 Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
40 'group_uom':fields.boolean("Manage Different Units of Measure for Products",
41 implied_group='product.group_uom',
42 help="""Allows you to select and maintain different units of measure for products."""),
43 'group_purchase_delivery_address': fields.boolean("Allow Different Addresses for Delivery and Invoice",
44 implied_group='purchase.group_delivery_invoice_address',
45 help="Allows you to specify different delivery and invoice addresses on a purchase order."),
46 'module_purchase_analytic_plans': fields.boolean('Use Multiple Analytic Accounts on Purchases',
47 help ="""Allows the user to maintain several analysis plans. These let you split
48 lines on a purchase order between several accounts and analytic plans.
49 This installs the module purchase_analytic_plans."""),
50 'module_warning': fields.boolean("Alerts by Products or Supplier",
51 help="""Allow to configure warnings on products and trigger them when a user wants to purchase a given product or a given supplier.
52 Example: Product: this product is deprecated, do not purchase more than 5.
53 Supplier: don't forget to ask for an express delivery."""),
55 'module_purchase_double_validation': fields.boolean("Two Levels of Approval",
56 help="""Provide a double validation mechanism for purchases exceeding minimum amount.
57 This installs the module purchase_double_validation."""),
58 'module_purchase_requisition': fields.boolean("Manage Purchase Requisitions",
59 help="""Purchase Requisitions are used when you want to request quotations from several suppliers for a given set of products.
60 You can configure per product if you directly do a Request for Quotation
61 to one supplier or if you want a purchase requisition to negotiate with several suppliers."""),
62 'decimal_precision': fields.integer('Decimal Precision on Price',help="As an example, a decimal precision of 2 will allow prices like: 9.99 EUR, whereas a decimal precision of 4 will allow prices like: 0.0231 EUR per unit."),
66 'default_invoice_method': 'manual',
69 def get_default_dp(self, cr, uid, fields, context=None):
70 dp = self.pool.get('ir.model.data').get_object(cr,uid, 'product','decimal_purchase')
71 return {'decimal_precision': dp.digits}
73 def set_default_dp(self, cr, uid, ids, context=None):
74 config = self.browse(cr, uid, ids[0], context)
75 dp = self.pool.get('ir.model.data').get_object(cr,uid, 'product','decimal_purchase')
76 dp.write({'digits': config.decimal_precision})
80 class account_config_settings(osv.osv_memory):
81 _inherit = 'account.config.settings'
83 'module_purchase_analytic_plans': fields.boolean('Several Analytic Accounts on Purchases',
84 help="""This allows install module purchase_analytic_plans."""),
85 'group_analytic_account_for_purchases': fields.boolean('Analytic Accounting for Purchases',
86 implied_group='purchase.group_analytic_accounting',
87 help="Allows you to specify an analytic account on purchase orders."),
90 def onchange_purchase_analytic_plans(self, cr, uid, ids, module_purchase_analytic_plans, context=None):
91 """ change group_analytic_account_for_purchases following module_purchase_analytic_plans """
92 return {'value': {'group_analytic_account_for_purchases': module_purchase_analytic_plans}}
94 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: