2012-03-02 12:43:57 +00:00
# -*- coding: utf-8 -*-
##############################################################################
#
2012-04-03 08:44:25 +00:00
# OpenERP, Open Source Business Applications
# Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
2012-03-02 12:43:57 +00:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields , osv
import pooler
from tools . translate import _
2012-03-22 11:03:58 +00:00
class purchase_config_settings ( osv . osv_memory ) :
_name = ' purchase.config.settings '
2012-03-05 09:09:23 +00:00
_inherit = ' res.config.settings '
2012-03-02 12:43:57 +00:00
_columns = {
2012-03-22 10:58:33 +00:00
' default_invoice_method ' : fields . selection (
2012-03-02 12:43:57 +00:00
[ ( ' manual ' , ' Based on Purchase Order Lines ' ) ,
( ' picking ' , ' Based on Receptions ' ) ,
( ' order ' , ' Pre-Generate Draft Invoices based on Purchase Orders ' ) ,
2012-07-31 13:48:16 +00:00
] , ' default invoicing control method ' , required = True , default_model = ' purchase.order ' ) ,
' group_purchase_pricelist ' : fields . boolean ( " manage pricelist per supplier " ,
2012-03-22 13:03:20 +00:00
implied_group = ' product.group_purchase_pricelist ' ,
help = """ Allows to manage different prices based on rules per category of Supplier.
Example : 10 % for retailers , promotion of 5 EUR on this product , etc . """ ),
2012-08-01 15:47:01 +00:00
' group_uom ' : fields . boolean ( " manage different units of measure for products " ,
2012-03-22 13:03:20 +00:00
implied_group = ' product.group_uom ' ,
2012-04-03 09:52:10 +00:00
help = """ Allows you to select and maintain different units of measure for products. """ ) ,
2012-08-01 15:47:01 +00:00
' group_purchase_delivery_address ' : fields . boolean ( " allow a different address for incoming products and invoicings " ,
2012-05-30 07:00:05 +00:00
implied_group = ' purchase.group_delivery_invoice_address ' ,
help = " Allows you to specify different delivery and invoice addresses on a purchase order. " ) ,
2012-07-31 13:48:16 +00:00
' module_purchase_analytic_plans ' : fields . boolean ( ' use multiple analytic accounts on orders ' ,
2012-03-22 10:58:33 +00:00
help = """ Allows the user to maintain several analysis plans. These let you split
lines on a purchase order between several accounts and analytic plans .
This installs the module purchase_analytic_plans . """ ),
2012-07-31 13:48:16 +00:00
' module_warning ' : fields . boolean ( " alerts by products or supllier " ,
2012-06-25 12:34:21 +00:00
help = """ Allow to configure warnings on products and trigger them when a user wants to purchase a given product or a given supplier.
2012-04-25 13:33:51 +00:00
Example : Product : this product is deprecated , do not purchase more than 5.
Supplier : don ' t forget to ask for an express delivery. " " " ),
2012-06-25 12:34:21 +00:00
2012-08-01 06:33:04 +00:00
' module_purchase_double_validation ' : fields . boolean ( " force two levels of approvals " ,
2012-03-22 10:58:33 +00:00
help = """ Provide a double validation mechanism for purchases exceeding minimum amount.
This installs the module purchase_double_validation . """ ),
2012-07-31 13:48:16 +00:00
' module_purchase_requisition ' : fields . boolean ( " manage purchase requisitions " ,
2012-06-25 12:34:21 +00:00
help = """ Purchase Requisitions are used when you want to request quotations from several suppliers for a given set of products.
You can configure per product if you directly do a Request for Quotation
2012-05-14 12:18:27 +00:00
to one supplier or if you want a purchase requisition to negotiate with several suppliers . """ ),
2012-07-31 13:48:16 +00:00
' decimal_precision ' : fields . integer ( ' specify 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. " ) ,
2012-03-02 12:43:57 +00:00
}
_defaults = {
2012-03-22 15:59:13 +00:00
' default_invoice_method ' : ' manual ' ,
2012-03-02 12:43:57 +00:00
}
2012-05-02 11:15:28 +00:00
def get_default_dp ( self , cr , uid , fields , context = None ) :
2012-05-09 13:58:56 +00:00
dp = self . pool . get ( ' ir.model.data ' ) . get_object ( cr , uid , ' product ' , ' decimal_purchase ' )
return { ' decimal_precision ' : dp . digits }
2012-05-02 11:15:28 +00:00
def set_default_dp ( self , cr , uid , ids , context = None ) :
config = self . browse ( cr , uid , ids [ 0 ] , context )
2012-05-09 13:58:56 +00:00
dp = self . pool . get ( ' ir.model.data ' ) . get_object ( cr , uid , ' product ' , ' decimal_purchase ' )
dp . write ( { ' digits ' : config . decimal_precision } )
2012-03-29 14:21:21 +00:00
class account_config_settings ( osv . osv_memory ) :
_inherit = ' account.config.settings '
_columns = {
2012-07-31 13:48:16 +00:00
' module_purchase_analytic_plans ' : fields . boolean ( ' use multiple analytic accounts on orders ' ,
2012-06-25 12:34:21 +00:00
help = """ This allows install module purchase_analytic_plans. """ ) ,
2012-03-29 14:21:21 +00:00
' group_analytic_account_for_purchases ' : fields . boolean ( ' Analytic Accounting for Purchases ' ,
implied_group = ' purchase.group_analytic_accounting ' ,
help = " Allows you to specify an analytic account on purchase orders. " ) ,
}
2012-06-25 12:34:21 +00:00
2012-06-08 11:56:39 +00:00
def onchange_purchase_analytic_plans ( self , cr , uid , ids , module_purchase_analytic_plans , context = None ) :
2012-06-25 12:34:21 +00:00
""" change group_analytic_account_for_purchases following module_purchase_analytic_plans """
return { ' value ' : { ' group_analytic_account_for_purchases ' : module_purchase_analytic_plans } }
2012-03-29 14:21:21 +00:00
2012-03-22 10:58:33 +00:00
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: