[IMP] set pricelist as a default

bzr revid: fka@tinyerp.com-20130307063531-6pnq7lictibbnybe
This commit is contained in:
Foram Katharotiya (OpenERP) 2013-03-07 12:05:31 +05:30
parent bdbb287f71
commit 39d3d6aa77
1 changed files with 8 additions and 1 deletions

View File

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