[FIX] uncomment code for on_change callback on product_id in account_tax_include module
[IMP] context *must* be None by default [IMP] membership/demo_data.xml is no more executable lp bug: https://launchpad.net/bugs/314343 fixed bzr revid: christophe@tinyerp.com-20090106133153-zl6mownzzloa14wl
This commit is contained in:
parent
3378bd4d3a
commit
5a4fce754f
|
@ -31,7 +31,7 @@ from tools import config
|
|||
from tools.translate import _
|
||||
|
||||
class account_invoice(osv.osv):
|
||||
def _amount_all(self, cr, uid, ids, name, args, context={}):
|
||||
def _amount_all(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for invoice in self.browse(cr,uid,ids, context=context):
|
||||
res[invoice.id] = {
|
||||
|
@ -47,6 +47,8 @@ class account_invoice(osv.osv):
|
|||
return res
|
||||
|
||||
def _get_journal(self, cr, uid, context):
|
||||
if context is None:
|
||||
context = {}
|
||||
type_inv = context.get('type', 'out_invoice')
|
||||
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
|
@ -63,7 +65,7 @@ class account_invoice(osv.osv):
|
|||
else:
|
||||
return pooler.get_pool(cr.dbname).get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
|
||||
|
||||
def _get_journal_analytic(self, cr, uid, type_inv, context={}):
|
||||
def _get_journal_analytic(self, cr, uid, type_inv, context=None):
|
||||
type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'}
|
||||
tt = type2journal.get(type_inv, 'sale')
|
||||
result = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=',tt)], context=context)
|
||||
|
@ -71,7 +73,9 @@ class account_invoice(osv.osv):
|
|||
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal of type '%s' !") % (tt,))
|
||||
return result[0]
|
||||
|
||||
def _get_type(self, cr, uid, context={}):
|
||||
def _get_type(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
type = context.get('type', 'out_invoice')
|
||||
return type
|
||||
|
||||
|
@ -84,7 +88,7 @@ class account_invoice(osv.osv):
|
|||
def _get_reference_type(self, cr, uid, context=None):
|
||||
return [('none', _('Free Reference'))]
|
||||
|
||||
def _amount_residual(self, cr, uid, ids, name, args, context={}):
|
||||
def _amount_residual(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
data_inv = self.browse(cr, uid, ids)
|
||||
for inv in data_inv:
|
||||
|
@ -113,19 +117,19 @@ class account_invoice(osv.osv):
|
|||
res[id]=[x for x in l if x <> line.id]
|
||||
return res
|
||||
|
||||
def _get_invoice_line(self, cr, uid, ids, context={}):
|
||||
def _get_invoice_line(self, cr, uid, ids, context=None):
|
||||
result = {}
|
||||
for line in self.pool.get('account.invoice.line').browse(cr, uid, ids, context=context):
|
||||
result[line.invoice_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
def _get_invoice_tax(self, cr, uid, ids, context={}):
|
||||
def _get_invoice_tax(self, cr, uid, ids, context=None):
|
||||
result = {}
|
||||
for tax in self.pool.get('account.invoice.tax').browse(cr, uid, ids, context=context):
|
||||
result[tax.invoice_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
def _compute_lines(self, cr, uid, ids, name, args, context={}):
|
||||
def _compute_lines(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
for invoice in self.browse(cr, uid, ids, context):
|
||||
moves = self.move_line_id_payment_get(cr, uid, [invoice.id])
|
||||
|
@ -373,7 +377,7 @@ class account_invoice(osv.osv):
|
|||
ok = ok and bool(cr.fetchone()[0])
|
||||
return ok
|
||||
|
||||
def button_reset_taxes(self, cr, uid, ids, context={}):
|
||||
def button_reset_taxes(self, cr, uid, ids, context=None):
|
||||
ait_obj = self.pool.get('account.invoice.tax')
|
||||
for id in ids:
|
||||
cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,))
|
||||
|
@ -381,7 +385,7 @@ class account_invoice(osv.osv):
|
|||
ait_obj.create(cr, uid, taxe)
|
||||
return True
|
||||
|
||||
def button_compute(self, cr, uid, ids, context={}, set_total=False):
|
||||
def button_compute(self, cr, uid, ids, context=None, set_total=False):
|
||||
self.button_reset_taxes(cr, uid, ids, context)
|
||||
for inv in self.browse(cr, uid, ids):
|
||||
if set_total:
|
||||
|
@ -626,7 +630,7 @@ class account_invoice(osv.osv):
|
|||
self._log_event(cr, uid, ids)
|
||||
return True
|
||||
|
||||
def line_get_convert(self, cr, uid, x, part, date, context={}):
|
||||
def line_get_convert(self, cr, uid, x, part, date, context=None):
|
||||
return {
|
||||
'date_maturity': x.get('date_maturity', False),
|
||||
'partner_id':part,
|
||||
|
@ -717,7 +721,7 @@ class account_invoice(osv.osv):
|
|||
self.pool.get('res.partner.event').create(cr, uid, {'name':'Invoice: '+name, 'som':False, 'description':name+' '+str(inv['id']), 'document':name, 'partner_id':part, 'date':time.strftime('%Y-%m-%d %H:%M:%S'), 'canal_id':False, 'user_id':uid, 'partner_type':partnertype, 'probability':1.0, 'planned_revenue':pr, 'planned_cost':pc, 'type':eventtype})
|
||||
return len(invs)
|
||||
|
||||
def name_get(self, cr, uid, ids, context={}):
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
return []
|
||||
types = {
|
||||
|
@ -731,7 +735,7 @@ class account_invoice(osv.osv):
|
|||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||
if not args:
|
||||
args=[]
|
||||
if not context:
|
||||
if context is None:
|
||||
context={}
|
||||
ids = []
|
||||
if name:
|
||||
|
@ -809,7 +813,9 @@ class account_invoice(osv.osv):
|
|||
new_ids.append(self.create(cr, uid, invoice))
|
||||
return new_ids
|
||||
|
||||
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context={}, name=''):
|
||||
def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''):
|
||||
if context is None:
|
||||
context = {}
|
||||
#TODO check if we can use different period for payment and the writeoff line
|
||||
assert len(ids)==1, "Can only pay one invoice at a time"
|
||||
invoice = self.browse(cr, uid, ids[0])
|
||||
|
@ -871,7 +877,9 @@ class account_invoice_line(osv.osv):
|
|||
res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2)
|
||||
return res
|
||||
|
||||
def _price_unit_default(self, cr, uid, context={}):
|
||||
def _price_unit_default(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if 'check_total' in context:
|
||||
t = context['check_total']
|
||||
for l in context.get('invoice_line', {}):
|
||||
|
@ -910,7 +918,7 @@ class account_invoice_line(osv.osv):
|
|||
'price_unit': _price_unit_default,
|
||||
}
|
||||
|
||||
def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context={}):
|
||||
def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=None):
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
if price_unit:
|
||||
taxes = tax_obj.browse(cr, uid, tax_id)
|
||||
|
@ -918,7 +926,9 @@ class account_invoice_line(osv.osv):
|
|||
price_unit = price_unit - tax['amount']
|
||||
return {'price_unit': price_unit,'invoice_line_tax_id': tax_id}
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, context={}):
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if not partner_id:
|
||||
raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") )
|
||||
if not product:
|
||||
|
@ -965,7 +975,7 @@ class account_invoice_line(osv.osv):
|
|||
domain = {'uos_id':[('category_id','=',res2 )]}
|
||||
return {'value':result, 'domain':domain}
|
||||
|
||||
def move_line_get(self, cr, uid, invoice_id, context={}):
|
||||
def move_line_get(self, cr, uid, invoice_id, context=None):
|
||||
res = []
|
||||
tax_grouped = {}
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
|
@ -1007,7 +1017,7 @@ class account_invoice_line(osv.osv):
|
|||
res[-1]['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, tax_amount, context={'date': inv.date_invoice})
|
||||
return res
|
||||
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
def move_line_get_item(self, cr, uid, line, context=None):
|
||||
return {
|
||||
'type':'src',
|
||||
'name': line.name[:64],
|
||||
|
|
|
@ -40,7 +40,7 @@ account_invoice()
|
|||
|
||||
class account_invoice_line(osv.osv):
|
||||
_inherit = "account.invoice.line"
|
||||
def _amount_line2(self, cr, uid, ids, name, args, context={}):
|
||||
def _amount_line2(self, cr, uid, ids, name, args, context=None):
|
||||
"""
|
||||
Return the subtotal excluding taxes with respect to price_type.
|
||||
"""
|
||||
|
@ -87,7 +87,9 @@ class account_invoice_line(osv.osv):
|
|||
res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], 2)
|
||||
return res
|
||||
|
||||
def _price_unit_default(self, cr, uid, context={}):
|
||||
def _price_unit_default(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if 'check_total' in context:
|
||||
t = context['check_total']
|
||||
if context.get('price_type', False) == 'tax_included':
|
||||
|
@ -116,7 +118,7 @@ class account_invoice_line(osv.osv):
|
|||
'price_unit': _price_unit_default,
|
||||
}
|
||||
|
||||
def move_line_get_item(self, cr, uid, line, context={}):
|
||||
def move_line_get_item(self, cr, uid, line, context=None):
|
||||
return {
|
||||
'type':'src',
|
||||
'name':line.name,
|
||||
|
@ -129,28 +131,30 @@ class account_invoice_line(osv.osv):
|
|||
'account_analytic_id':line.account_analytic_id.id,
|
||||
}
|
||||
|
||||
# TODO: check why ?
|
||||
#
|
||||
# def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context={}):
|
||||
# if context.get('price_type', False) == 'tax_included':
|
||||
# return {'price_unit': price_unit,'invoice_line_tax_id': tax_id}
|
||||
# else:
|
||||
# return super(account_invoice_line, self).product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
|
||||
#
|
||||
# def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, price_type='tax_excluded', context={}):
|
||||
# context.update({'price_type': price_type})
|
||||
# return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, price_unit, address_invoice_id, context=context)
|
||||
def product_id_change_unit_price_inv(self, cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
# if the tax is already included, just return the value without calculations
|
||||
if context.get('price_type', False) == 'tax_included':
|
||||
return {'price_unit': price_unit,'invoice_line_tax_id': tax_id}
|
||||
else:
|
||||
return super(account_invoice_line, self).product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
|
||||
|
||||
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, price_unit=False, address_invoice_id=False, price_type='tax_excluded', context=None):
|
||||
# note: will call product_id_change_unit_price_inv with context...
|
||||
if context is None:
|
||||
context = {}
|
||||
context.update({'price_type': price_type})
|
||||
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, price_unit, address_invoice_id, context=context)
|
||||
account_invoice_line()
|
||||
|
||||
class account_invoice_tax(osv.osv):
|
||||
_inherit = "account.invoice.tax"
|
||||
|
||||
def compute(self, cr, uid, invoice_id, context={}):
|
||||
def compute(self, cr, uid, invoice_id, context=None):
|
||||
inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id)
|
||||
line_ids = map(lambda x: x.id, inv.invoice_line)
|
||||
|
||||
|
||||
|
||||
tax_grouped = {}
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
cur_obj = self.pool.get('res.currency')
|
||||
|
|
Loading…
Reference in New Issue