Odoo Help

0

0
3 Answers
2
Avatar

Niyas Raphy

--Niyas Raphy--
24469
| 7 7 11
Wayanad, India
--Niyas Raphy--

Odoo Techno Functionalist

Feel free to connect :  niyasraphyk@gmail.com

Twitter:https://twitter.com/niyasraphy
LinkedIn: https://www.linkedin.com/in/niyasraphy/
FB:https://www.facebook.com/niyasraphy123

Happy to help :)

Niyas Raphy
16/3/18 01:25

Hi,

Try like this,

@api.depends('order_line.commission_line')
def _commission_amount(self):
for order in self:
comm_total = 0.0
for line in order.order_line:
comm_total += line.commission_line
order.update({'commission': comm_total })


Thanks

0
Ahmed Vahed
21/5/19 08:04

Neither of the above worked for me. I created a float variable x_studio_nett_untaxed_total_1 with Related field order_line.x_studio_nett_total - another field I created. It is only using the first line of the order as the total. I have tried both ways above.

Related Field : order_line.x_studio_nett_total

De[endencies : order_line.x_studio_nett_total, x_studio_nett_untaxed_total_1

Computed : 

@api.depends('order_line.x_studio_nett_total')

def _line_total(self) :

for order in self:

  line_total = 0.0

  for line in order.order_line:  

    line_total += line.x_studio_nett_total

  order.update({'x_studio_nett_untaxed_total_1':line_total})

0
Michael Yeung
24/7/18 13:33

Sorry for off topic! @Niyas, you are the best! I applied the formula on the total discount for SO with computed field. Sharing for reference...

float field on sale.order.line, x_price_discount_amount;

float field on sale.order, x_price_discount_amount_total, depends=order_line.x_price_discount_amount

for record in self:
  discount_total = 0.0
  for line in record.order_line:  
    discount_total += line.x_price_discount_amount
  record['x_price_discount_amount_total'] = discount_total

It works! Thanks so much.

Ask a Question
Writer
Keep Informed
2 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our eLearning platform and experience all Odoo Apps through learning videos, use cases and quizzes.

Test it now