Odoo Help

0

0
1 Answer
1
Avatar

Niyas Raphy

--Niyas Raphy--
24330
| 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
7/4/19 09:13

Hi,

If you are looking to display/get the no of the stock-able product in the sale order, you can add a compute field in the sale order model and compute the count into it.

stock_product_count = fields.Integer(string='Count', compute='get_pro_count')


@api.multi
def get_pro_count(self):
for rec in self:
count = 0
for line in rec.order_line:
if line.product_id.type == 'product':
count += 1
rec.stock_product_count = count


Thanks

2 Comments
mostafa
7/4/19 09:30

raise ValueError("Expected singleton: %s" % self)

ValueError: Expected singleton: sale.order(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)

Niyas Raphy
7/4/19 09:55

Hope you have added the field in tree view also, you can update the code like this,

@api.multi

def get_pro_count(self):

for rec in self:

count = 0

for line in rec.order_line:

if line.product_id.type == 'product':

count += 1

rec.stock_product_count = count

Ask a Question
Writer
Keep Informed
1 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