Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
5580 Vistas

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
Descartar
Autor Mejor respuesta

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
Descartar

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,})]

Autor

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.

Mejor respuesta

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
Descartar

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

Publicaciones relacionadas Respuestas Vistas Actividad
3
dic 22
3615
2
abr 20
4530
1
abr 20
3473
2
sept 19
9055
0
jun 21
3332