[FIX] According to Xavier (OpenERP) to fit OpenERP requierements : remove commented code, use != instead of <>, fix picking wizard.

bzr revid: joel.grandguillaume@camptocamp.com-20100215103948-cbnngoh2px14pk6a
This commit is contained in:
Joël Grand-Guillaume 2010-02-15 11:39:48 +01:00
parent 94eca59637
commit 8da7540388
7 changed files with 13 additions and 98 deletions

View File

@ -37,7 +37,7 @@ class account_analytic_line(osv.osv):
cmp_cur_id=rec.company_id.currency_id.id
aa_cur_id=rec.account_id.currency_id.id
# Always provide the amount in currency
if cmp_cur_id <> aa_cur_id:
if cmp_cur_id != aa_cur_id:
cur_obj = self.pool.get('res.currency')
ctx = {}
if rec.date and rec.amount:

View File

@ -81,18 +81,6 @@ class account_analytic_account(osv.osv):
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
# Expense amount and purchase invoice
#acc_set = ",".join(map(str, ids2))
#cr.execute ("select account_analytic_line.account_id, sum(amount) \
# from account_analytic_line \
# join account_analytic_journal \
# on account_analytic_line.journal_id = account_analytic_journal.id \
# where account_analytic_line.account_id IN (%s) \
# and account_analytic_journal.type = 'purchase' \
# GROUP BY account_analytic_line.account_id;"%acc_set)
#for account_id, sum in cr.fetchall():
# res2[account_id] = round(sum,2)
for obj_id in ids:
res.setdefault(obj_id, 0.0)
res2.setdefault(obj_id, 0.0)
@ -171,74 +159,8 @@ class account_analytic_account(osv.osv):
for account_id, sum in cr.fetchall():
res[account_id] = round(sum,2)
return self._compute_currency_for_level_tree(cr, uid, ids, ids2, res, acc_set, context)
# TODO Take care of pricelist and purchase !
# def _ca_theorical_calc(self, cr, uid, ids, name, arg, context={}):
# res = {}
# res2 = {}
# date = time.strftime('%Y-%m-%d')
# ids2 = self.search(cr, uid, [('parent_id', 'child_of', ids)])
# # Take care of pricelist unit_price on all hours
# if ids2:
# acc_set = ",".join(map(str, ids2))
# cr.execute("""select account_analytic_line.account_id as account_id, \
# COALESCE(sum((account_analytic_line.unit_amount * pt.list_price) \
# - (account_analytic_line.unit_amount * pt.list_price \
# * hr.factor)),0.0) as somme,\
# account_analytic_line.unit_amount as qty,
# a.pricelist_id as pricelist,
# account_analytic_line.product_id as product,
# a.partner_id as partner_id
# from account_analytic_line \
# left join account_analytic_journal \
# on (account_analytic_line.journal_id = account_analytic_journal.id) \
# join product_product pp \
# on (account_analytic_line.product_id = pp.id) \
# join product_template pt \
# on (pp.product_tmpl_id = pt.id) \
# join account_analytic_account a \
# on (a.id=account_analytic_line.account_id) \
# join hr_timesheet_invoice_factor hr \
# on (hr.id=a.to_invoice) \
# where account_analytic_line.account_id IN (%s) \
# and a.to_invoice IS NOT NULL \
# and account_analytic_journal.type in ('purchase','general')
# GROUP BY account_analytic_line.account_id,"""%acc_set)
# # Compute unit amount with pricelist for given qty and product
# for account_id, sum, qty, pricelist,product, partner_id in cr.fetchall():
# # If no product, no pricelist or no partner_id, no need to compute
# if not pricelist or not product or not partner_id:
# res2[account_id] = 0,0
# else:
# unit_price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist],
# product, qty or 1.0, partner_id, {
# 'date': date,
# })[pricelist]
# if unit_price is False:
# warning = {
# 'title': 'No valid pricelist line found !',
# 'message':
# "Couldn't find a pricelist line matching this product and quantity.\n"
# "You have to change either the product, the quantity or the pricelist."
# }
# else:
# res2[account_id] = round(unit_price,2)
#
# for obj_id in ids:
# res.setdefault(obj_id, 0.0)
# res2.setdefault(obj_id, 0.0)
# for child_id in self.search(cr, uid,
# [('parent_id', 'child_of', [obj_id])]):
# if child_id != obj_id:
# res[obj_id] += res.get(child_id, 0.0)
# res[obj_id] += res2.get(child_id, 0.0)
#
# # sum both result on account_id
# for id in ids:
# res[id] = round(res.get(id, 0.0),2) + round(res2.get(id, 0.0),2)
# return res
def _ca_theorical_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
res2 = {}
@ -352,7 +274,7 @@ class account_analytic_account(osv.osv):
def _remaining_hours_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
for account in self.browse(cr, uid, ids):
if account.quantity_max <> 0:
if account.quantity_max != 0:
res[account.id] = account.quantity_max - account.hours_quantity
else:
res[account.id]=0.0
@ -386,7 +308,7 @@ class account_analytic_account(osv.osv):
for account in self.browse(cr, uid, ids):
if account.ca_invoiced == 0:
res[account.id]=0.0
elif account.total_cost <> 0.0:
elif account.total_cost != 0.0:
res[account.id] = -(account.real_margin / account.total_cost) * 100
else:
res[account.id] = 0.0
@ -397,7 +319,7 @@ class account_analytic_account(osv.osv):
def _remaining_ca_calc(self, cr, uid, ids, name, arg, context={}):
res = {}
for account in self.browse(cr, uid, ids):
if account.amount_max <> 0:
if account.amount_max != 0:
res[account.id] = account.amount_max - account.ca_invoiced
else:
res[account.id]=0.0

View File

@ -43,9 +43,9 @@ class account_analytic_account(osv.osv):
if id not in ids2:
continue
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
if child <> id:
if child != id:
res.setdefault(id, 0.0)
if currency[child]<>currency[id]:
if currency[child]!=currency[id]:
res[id] += res_currency.compute(cr, uid, currency[child], currency[id], res.get(child, 0.0), context=context)
else:
res[id] += res.get(child, 0.0)
@ -152,7 +152,7 @@ class account_analytic_account(osv.osv):
if id not in ids2:
continue
for child in self.search(cr, uid, [('parent_id', 'child_of', [id])]):
if child <> id:
if child != id:
res.setdefault(id, 0.0)
res[id] += res.get(child, 0.0)
return dict([(i, res[i]) for i in ids])

View File

@ -52,15 +52,9 @@ class account_analytic_account(osv.osv):
res[id] = round(res.get(id, 0.0),2)
return res
# def _get_account_currency(self, cr, uid, ids, field_name, arg, context={}):
# result=super(account_analytic_account, self)._get_account_currency(cr, uid, ids, field_name, arg, context)
# for rec in self.browse(cr, uid, ids, context):
# result[rec.id] = rec.pricelist_id and (rec.pricelist_id.currency_id.id,rec.pricelist_id.currency_id.code) or result[rec.id]
# return result
_inherit = "account.analytic.account"
_columns = {
# 'currency_id': fields.function(_get_account_currency, method=True, type='many2one', relation='res.currency', string='Account currency', store=True),
'pricelist_id' : fields.many2one('product.pricelist', 'Sale Pricelist'),
'amount_max': fields.float('Max. Invoice Price'),
'amount_invoiced': fields.function(_invoiced_calc, method=True, string='Invoiced Amount',

View File

@ -664,7 +664,6 @@ class stock_picking(osv.osv):
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
return amount_unit
# return move_line.product_id.standard_price
else:
return move_line.product_id.list_price

View File

@ -55,7 +55,7 @@ def _get_moves(self, cr, uid, data, context):
for move in move_lines:
quantity = move.product_qty
if move.state <> 'assigned':
if move.state != 'assigned':
quantity = 0
_moves_arch_lst.append('<field name="move%s" />' % (move.id,))
@ -136,7 +136,7 @@ def _do_split(self, cr, uid, data, context):
else:
# Get the standard price
amount_unit=product.price_get(pricetype.field, context)[product.id]
new_std_price = ((product.amount_unit * product.qty_available)\
new_std_price = ((amount_unit * product.qty_available)\
+ (new_price * qty))/(product.qty_available + qty)
product_obj.write(cr, uid, [product.id],
@ -144,7 +144,7 @@ def _do_split(self, cr, uid, data, context):
move_obj.write(cr, uid, move.id, {'price_unit': new_price})
for move in too_few:
if data['form']['move%s' % move.id] <> 0:
if data['form']['move%s' % move.id] != 0:
new_move = move_obj.copy(cr, uid, move.id,
{
'product_qty' : data['form']['move%s' % move.id],

View File

@ -61,7 +61,7 @@ def _get_moves(self, cr, uid, data, context):
if m.state in ('done', 'cancel'):
continue
quantity = m.product_qty
if m.state<>'assigned':
if m.state!='assigned':
quantity = 0
_moves_arch_lst.append('<field name="move%s" />' % (m.id,))
@ -161,7 +161,7 @@ def _do_split(self, cr, uid, data, context):
'move_lines' : [],
'state':'draft',
})
if data['form']['move%s' % move.id] <> 0:
if data['form']['move%s' % move.id] != 0:
new_obj = move_obj.copy(cr, uid, move.id,
{
'product_qty' : data['form']['move%s' % move.id],