[FIX] sale: set a default value for a required field not present in form view for most of people
bzr revid: qdp-launchpad@openerp.com-20130103101045-32yq65xcibon2a35
This commit is contained in:
parent
11db0f89fe
commit
18a26bac3a
|
@ -178,6 +178,13 @@ class sale_order(osv.osv):
|
|||
result[line.order_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
def _get_default_shop(self, cr, uid, context=None):
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||
shop_ids = self.pool.get('sale.shop').search(cr, uid, [('company_id','=',company_id)], context=context)
|
||||
if not shop_ids:
|
||||
raise osv.except_osv(_('Error!'), _('There is no default shop for the current user\'s company!'))
|
||||
return shop_ids[0]
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Order Reference', size=64, required=True,
|
||||
readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
|
||||
|
@ -251,6 +258,7 @@ class sale_order(osv.osv):
|
|||
'user_id': lambda obj, cr, uid, context: uid,
|
||||
'name': lambda obj, cr, uid, context: '/',
|
||||
'invoice_quantity': 'order',
|
||||
'shop_id': _get_default_shop,
|
||||
'partner_invoice_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['invoice'])['invoice'],
|
||||
'partner_shipping_id': lambda self, cr, uid, context: context.get('partner_id', False) and self.pool.get('res.partner').address_get(cr, uid, [context['partner_id']], ['delivery'])['delivery'],
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue