[FIX] small fixes
- set the company_id parameters at the end of the method to avoid incompatibities with calls in account_analytic_plans - instead of checking the context, actually pass the company_id argument in the product_change from uos_id_change
This commit is contained in:
parent
37bff3b62c
commit
46bf4db884
|
@ -1546,7 +1546,7 @@ class account_invoice_line(osv.osv):
|
||||||
context = dict(context)
|
context = dict(context)
|
||||||
context.update({'company_id': company_id})
|
context.update({'company_id': company_id})
|
||||||
warning = {}
|
warning = {}
|
||||||
res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context)
|
res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context, company_id=company_id)
|
||||||
if not uom:
|
if not uom:
|
||||||
res['value']['price_unit'] = 0.0
|
res['value']['price_unit'] = 0.0
|
||||||
if product and uom:
|
if product and uom:
|
||||||
|
|
|
@ -39,7 +39,7 @@ class account_analytic_default(osv.osv):
|
||||||
'date_stop': fields.date('End Date', help="Default end date for this Analytic Account."),
|
'date_stop': fields.date('End Date', help="Default end date for this Analytic Account."),
|
||||||
}
|
}
|
||||||
|
|
||||||
def account_get(self, cr, uid, product_id=None, partner_id=None, company_id=None, user_id=None, date=None, context=None):
|
def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, company_id=None, context=None):
|
||||||
domain = []
|
domain = []
|
||||||
if product_id:
|
if product_id:
|
||||||
domain += ['|', ('product_id', '=', product_id)]
|
domain += ['|', ('product_id', '=', product_id)]
|
||||||
|
@ -78,10 +78,7 @@ class account_invoice_line(osv.osv):
|
||||||
|
|
||||||
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None):
|
||||||
res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id=currency_id, context=context, company_id=company_id)
|
res_prod = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom_id, qty, name, type, partner_id, fposition_id, price_unit, currency_id=currency_id, context=context, company_id=company_id)
|
||||||
if context is None:
|
rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), company_id=company_id, context=context)
|
||||||
context = {}
|
|
||||||
company_id = company_id if company_id != None else context.get('company_id',False)
|
|
||||||
rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, company_id, uid, time.strftime('%Y-%m-%d'), context=context)
|
|
||||||
if rec:
|
if rec:
|
||||||
res_prod['value'].update({'account_analytic_id': rec.analytic_id.id})
|
res_prod['value'].update({'account_analytic_id': rec.analytic_id.id})
|
||||||
else:
|
else:
|
||||||
|
@ -95,7 +92,7 @@ class stock_picking(osv.osv):
|
||||||
|
|
||||||
def _get_account_analytic_invoice(self, cursor, user, picking, move_line):
|
def _get_account_analytic_invoice(self, cursor, user, picking, move_line):
|
||||||
partner_id = picking.partner_id and picking.partner_id.id or False
|
partner_id = picking.partner_id and picking.partner_id.id or False
|
||||||
rec = self.pool.get('account.analytic.default').account_get(cursor, user, move_line.product_id.id, partner_id, company_id, user, time.strftime('%Y-%m-%d'), context={})
|
rec = self.pool.get('account.analytic.default').account_get(cursor, user, move_line.product_id.id, partner_id, user, time.strftime('%Y-%m-%d'))
|
||||||
|
|
||||||
if rec:
|
if rec:
|
||||||
return rec.analytic_id.id
|
return rec.analytic_id.id
|
||||||
|
@ -116,7 +113,7 @@ class sale_order_line(osv.osv):
|
||||||
anal_def_obj = self.pool.get('account.analytic.default')
|
anal_def_obj = self.pool.get('account.analytic.default')
|
||||||
|
|
||||||
for line in inv_line_obj.browse(cr, uid, create_ids, context=context):
|
for line in inv_line_obj.browse(cr, uid, create_ids, context=context):
|
||||||
rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, sale_line.order_id.user_id.id, False, time.strftime('%Y-%m-%d'), context=context)
|
rec = anal_def_obj.account_get(cr, uid, line.product_id.id, sale_line.order_id.partner_id.id, sale_line.order_id.user_id.id, time.strftime('%Y-%m-%d'), context=context)
|
||||||
|
|
||||||
if rec:
|
if rec:
|
||||||
inv_line_obj.write(cr, uid, [line.id], {'account_analytic_id': rec.analytic_id.id}, context=context)
|
inv_line_obj.write(cr, uid, [line.id], {'account_analytic_id': rec.analytic_id.id}, context=context)
|
||||||
|
|
Loading…
Reference in New Issue