Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
5728 Widoki

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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!! 

Awatar
Odrzuć

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.

Najlepsza odpowiedź

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

   

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
3
gru 22
3774
2
kwi 20
4710
1
kwi 20
3668
2
wrz 19
9296
0
cze 21
3478