Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

POS (order menu Error)[SOLVE] [Closed]

By
Alcaline
on 11/19/14, 10:53 PM 910 views

The Question has been closed for reason: off-topic or not relevant

by
Alcaline
on 11/20/2014 03:29:52

Server Traceback (most recent call last): File "/opt/openerp/server-7/openerp/addons/web/session.py", line 90, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server-7/openerp/netsvc.py", line 293, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server-7/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server-7/openerp/osv/osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server-7/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server-7/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/server-7/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/server-7/openerp/osv/orm.py", line 3604, in read result = self._read_flat(cr, user, select, fields, context, load) File "/opt/openerp/server-7/openerp/osv/orm.py", line 3712, in _read_flat res2 = self._columns[val[0]].get(cr, self, ids, val, user, context=context, values=res) File "/opt/openerp/server-7/openerp/osv/fields.py", line 1131, in get result = self._fnct(obj, cr, uid, ids, name, self._arg, context) File "/opt/openerp/server-7/openerp/addons/point_of_sale/point_of_sale.py", line 575, in _amount_all val2 += line.price_subtotal

TypeError: unsupported operand type(s) for +=: 'float' and 'dict'

 

I add an additional field in ORDER for discount. but when i override the _amount_line_all in pos.order.line and add some computation there is an error occured in _amount_all def that can from in pos.order. Can someone here please help me?

Here is my code:

def _amount_line_all(self, cr, uid, ids, field_names, arg, context=None):
        res = dict([(i, {}) for i in ids])
        account_tax_obj = self.pool.get('account.tax')
        cur_obj = self.pool.get('res.currency')
        for line in self.browse(cr, uid, ids, context=context):
            taxes_ids = [ tax for tax in line.product_id.taxes_id if tax.company_id.id == line.order_id.company_id.id ]
            price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
            if line.cod_amount > 0:
                 price = line.cod_amount
              
            taxes = account_tax_obj.compute_all(cr, uid, taxes_ids, price, line.qty, product=line.product_id, partner=line.order_id.partner_id or False)

            cur = line.order_id.pricelist_id.currency_id
            res[line.id]['price_subtotal'] = cur_obj.round(cr, uid, cur, taxes['total'])
            res[line.id]['price_subtotal_incl'] = cur_obj.round(cr, uid, cur, taxes['total_included'])
        return res

 

    def onchange_qty(self, cr, uid, ids, product, discount=False, qty=False, price_unit=False, bo_disc=False, cod_disc=False, context=None):
        result = {}
        if not product:
            return result
        account_tax_obj = self.pool.get('account.tax')
        cur_obj = self.pool.get('res.currency')

        prod = self.pool.get('product.product').browse(cr, uid, product, context=context)

        price = price_unit * (1 - (discount or 0.0) / 100.0)
        taxes = account_tax_obj.compute_all(cr, uid, prod.taxes_id, price, qty, product=prod, partner=False)
   
        
        disc = 0.0
        disc1 = 0.0
        disc2 = 0.0
 
        if price_unit > 0:
            if discount > 0:  
                        
                    disc = (1 - (discount or 0.0000) / 100.0000) * price_unit
                    netsvc.Logger().notifyChannel("333333333..",netsvc.LOG_INFO, '' +'333333aaaaaa' + str(disc))
       
                    if bo_disc > 0 :
                            
                        disc1 = disc * (1 - (bo_disc or 0.0000) / 100.0000)
                        
                        if cod_disc > 0:
                             
                                 
                            disc2 = disc1 * (1 - (cod_disc / 100.0000))
                           
                            
       
        result['disc_amount'] = disc
        result['bo_amount'] = disc1
        result['cod_amount'] = disc2

        result['price_subtotal'] = taxes['total']
        result['price_subtotal_incl'] = taxes['total_included']
        return {'value': result}

 

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/19/14, 10:53 PM
Seen: 910 times
Last updated: 3/16/15, 8:10 AM