From 39d3d6aa7759d1e0f89ef2ed3d81c6e9ebfe225a Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Thu, 7 Mar 2013 12:05:31 +0530 Subject: [PATCH] [IMP] set pricelist as a default bzr revid: fka@tinyerp.com-20130307063531-6pnq7lictibbnybe --- addons/hr_timesheet_invoice/hr_timesheet_invoice.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 6181ec45e12..ace3b0b489a 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -70,6 +70,13 @@ class account_analytic_account(osv.osv): invoice_id = False return invoice_id + def _get_default_pricelist_id(self, cr, uid, context=None): + try: + pricelist_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'product', 'list0')[1] + except ValueError: + pricelist_id = False + return pricelist_id + _inherit = "account.analytic.account" _columns = { 'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', @@ -82,7 +89,7 @@ class account_analytic_account(osv.osv): help="You usually invoice 100% of the timesheets. But if you mix fixed price and timesheet invoicing, you may use another ratio. For instance, if you do a 20% advance invoice (fixed price, based on a sales order), you should invoice the rest on timesheet with a 80% ratio."), } _defaults = { - 'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False), + 'pricelist_id': _get_default_pricelist_id, 'to_invoice': _get_default_to_invoice, }