It is currently Mon May 21, 2012 6:40 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Add commissions
PostPosted: Sun May 22, 2011 5:25 pm 
Offline

Joined: Thu Dec 03, 2009 4:30 pm
Posts: 18
I'd like to add a commission to sales modules, but when I edit I don't get any result.
The code I am duplicating is this:

def _amount_line_tax(self, cr, uid, line, context=None):
val = 0.0
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1+(line.discount or 0.0)/100.0), line.product_uom_qty, line.order_id.partner_invoice_id.id, line.
product_id, line.order_id.partner_id)['taxes']:
val += c.get('amount', 0.0)
return val

def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
cur_obj = self.pool.get('res.currency')
res = {}
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_untaxed': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
val = val1 = 0.0
cur = order.pricelist_id.currency_id
for line in order.order_line:
val1 += line.price_subtotal
val += self._amount_line_tax(cr, uid, line, context=context)
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val) res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
return res

def _amount_line_prodfee(self, cr, uid, line, context=None):
val = 0.0
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1+(line.discount or 0.0)/100.0), line.product_uom_qty, line.order_id.partner_invoice_id.id, line.
product_id, line.order_id.partner_id)['taxes']:
val += c.get('amount', 0.0)
return val


def _amount_prodfee(self, cr, uid, ids, field_name, arg, context=None):
cur_obj = self.pool.get('res.currency')
res = {}
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_nofee': 0.0,
'amount_prodfee': 0.0,
'amount_totalfee': 0.0,
}
val = val1 = 0.0
cur = order.pricelist_id.currency_id
for line in order.order_line:
val1 += line.price_subtotal
val += self._amount_line_tax(cr, uid, line, context=context)
res[order.id]['amount_nofee'] = cur_obj.round(cr, uid, cur, val)
res[order.id]['amount_prodfee'] = cur_obj.round(cr, uid, cur, val1)
res[order.id]['amount_totalfee'] = res[order.id]['amount_prodfee'] + res[order.id]['amount_nofee']
return res


I have added below the definitions of amount_nofee, amount_prodfee and amount_totalfee and I have inserted all of them in the db.
Where do I mistake?


Top
 Profile  
 
 Post subject: Re: Add commissions
PostPosted: Sun May 22, 2011 6:55 pm 
Offline

Joined: Sun Dec 28, 2008 1:03 pm
Posts: 190
Location: Genoa
Did you see these http://apps.openerp.com/?text_search=commission ?

_________________
Lorenzo Battistini
http://planet.domsense.com/en/author/elbati/
http://www.agilebg.com/


Top
 Profile  
 
 Post subject: Re: Add commissions
PostPosted: Mon May 23, 2011 10:09 am 
Offline

Joined: Thu Dec 03, 2009 4:30 pm
Posts: 18
Thank you eLBati, but I'd like to add a commission to a product, managed @company layer, and explicit it inside the report (I know my customer is crazy).
Now I'd like to know: if I modify the sale.py and then I restart openerp-server is enough?
Or do I have to compile something?
Thanks a lot... :)


Top
 Profile  
 
 Post subject: Re: Add commissions
PostPosted: Mon May 23, 2011 10:33 am 
Offline

Joined: Thu Sep 23, 2010 9:29 pm
Posts: 251
Location: Leeseringen, Germany
If you modify code, you must update the module.

Either by specifying -d database -u modulename while starting the openerp server, or in OpenERP on the modules form with the button Schedule Upgrade.

_________________
Light travels faster than sound.
That is why some people appear bright until you hear them speak.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP