Skip to Content
Menu
This question has been flagged
2 Replies
4492 Views

I have created a wizard which adds a product bundle to sale.order.line along with the quantity. The .py of wizard is hereby:

lass SaleView(models.TransientModel):
_name = "sale.order.wizard"

#list of field used in wizard given here
product_name = fields.Many2one("product.product", string="Product Name", required=True)
quantity = fields.Float(string="Quantity", default=1.0)


@api.multi
def button_send(self):
#this function is used to create a new product list in sale.order.line
#after clicking add pack button in wizard of sale.order.wizard
for line in self.product_name:
self.env['sale.order.line'].create({
'product_id': line.id,
'product_uom_qty': self.quantity,
'order_id': self._context.get('active_id')
})
return True            I want to update quantity when product_uom_qty in sale.order.line is changed. Does anyone have any idea how to do it. Please help me. Thanks in advance..

Avatar
Discard
Author Best Answer

Thanks, But i know that already. I just want to update that field value in the sale order line when the qty field in sale order line is changed not the wizard value but the passed value. So if u have any idea then please provide me. Thanks!! 

Avatar
Discard

Hello Riyan,

Okay so to update the Sale orderline field "product_uom_qty" based on the wizard field value "Quantity". You can try this below code.

@api.multi

def button_send(self):

context = self.env.context

active_ids = context.get('active_ids')

for sale_rec in self.env['sale.order'].browse(active_ids):

sale_rec.order_line = [(0, 0, {'product_id': self.product_name.id,

'product_uom_qty': self.quantity,})]

Author

The above button_send in my code sends a product_pack to the sale order line when the button is clicked. Now i want to update the quantity that was previously passed through the function button_send when product_uom_qty is changed in value. Does your code perform that i'm not sure if you have any idea it will be very helpful. Thanks... In simply you can say i want to reverse the action of button_send and place the value back again in sale.order.line.

Best Answer

Hello Riyan,


Transient Model never stores the values of fields in the database.
So we could not update the value of Quantity field which is defined in Transient Model.



Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Discard

Wrong, they are stored, then deleted after 5minutes(default value) by a cron task.

It might not be the answer of why we can't

Related Posts Replies Views Activity
3
Dec 22
2629
2
Apr 20
3558
1
Apr 20
2413
2
Sep 19
7205
0
Jun 21
2256