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, }