hello everyone,
i have create one wizard .in this wizard i add many2many fields (product.product).
now i want delete record which is selcet in my wizard many2many fields .
how can i do this anyone can help??
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hello everyone,
i have create one wizard .in this wizard i add many2many fields (product.product).
now i want delete record which is selcet in my wizard many2many fields .
how can i do this anyone can help??
Hello Ra_one_1_11,
Please find code in comment.
I hope this will help you.
Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari
To delete one2many line through wizard inherit create method of your wizard as below,
class YourWizard(model):
....
@api.model_create_multi
def create(self, vals):
sale_order_obj = self.env[‘sale.order’] # SaleOrder Recordset
order_line_obj = self.env['sale.order.line']
order_line_rm = []
for val in vals:
if val['product_ids']:
for product_id in val['product_ids'][0][2]:
if product_id in sale_order_obj.order_line.product_id.ids:
order_line_rm.extend(order_line_obj.search([('product_id', '=', product_id), ('id', 'in', sale_order_obj.order_line.ids)]).ids)
if order_line_rm:
sale_order_obj.write({
'order_line': [[3, id] for id in order_line_rm]
})
return super(YourWizard, self).create(vals)
For referance I create function to delete orderline from “sale.order” model.
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit se| Related Posts | Odpovědi | Zobrazení | Aktivita | |
|---|---|---|---|---|
|
1
pro 25
|
434 | |||
|
3
zář 25
|
3864 | |||
|
0
srp 25
|
1233 | |||
|
1
srp 25
|
3646 | |||
|
2
čvc 25
|
9293 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.