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!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
1
Dec 25
|
428 | |||
|
3
Sep 25
|
3857 | |||
|
0
Aug 25
|
1232 | |||
|
1
Aug 25
|
3644 | |||
|
2
Jul 25
|
9289 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.