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

How to modify amount_total from pos_order

By
Matthieu
on 5/10/16, 4:35 AM 271 views

Hi,

I'm using Odoo 9 and I would like to add a value to amount_total from pos_order.

I tried different things that didn't work as for example inherit _amount_all or use the write function on self.pool.get('pos.order').browse(cr, uid, ids, context=context).

Please help me.

Thanks.

2

Prakash Sharma

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 5/10/16, 4:59 AM

amount total is function/compute fields ,

As compute fields not store in db so you can modify it with the write.

you can override the function associated with the compute filed to modify it's value.  

  'amount_total': fields.function(_amount_all, string='Total', digits_compute=dp.get_precision('Account'),  multi='all'),

override  _amount_all  method .


Currently, my code is this : def _amount_all(self, cr, uid, ids, name, args, context=None): res = super(pos_order, self)._amount_all(cr, uid, ids, name, args, context) for order in self.browse(cr, uid, ids, context=context): res[order.id]['amount_total'] += 42 return res But the value "42" isn't added to amount_total. Can you help me please ?

Matthieu
on 5/11/16, 5:00 AM
1
Hunzala
On 5/10/16, 8:39 AM

Hello,

I hope everyone is in good health. I am trying Odoo for test purposes.  I have created the sales order of about 6 items and I assigned them to the different team. My question is that is there any way that I can create the invoice for all 6 items separately from only one account? I have created two invoices of the sales order from two different accounts i.e. Administrator and demo account but for that I had to delete rest of the items in the list and after doing that I was unable to create any more invoice for that sales order from those account. I want to know if I can create separate invoice for all the items.

1
Matthieu
On 5/10/16, 5:26 AM

Thank you, I understood more that amount_total is generated by _amount_all.

So, I tried to inherit as you said but I think I did something wrong.
Here is my code :

def _amount_all(self, cr, uid, ids, name, args, context=None):

res = super(pos_order, self)._amount_all(cr, uid, ids, name, args, context)

for order in self.browse(cr, uid, ids, context=context):

      res[order.id]['amount_total'] += order.coupon_nb

return res

 

Should I override the attributes in "_columns" or the xml view ? Cause it doesn't work for the moment...

Matthieu
on 5/10/16, 6:26 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 5/10/16, 4:35 AM
Seen: 271 times
Last updated: 5/11/16, 4:58 AM