How to remove data from Many2many field via custom method in wizard in odoo 10?












1















I have two views :
1. Registration form view
2 Update Registration Wizard view.
Models :
1 Registration
2 Members



I am setting up a registration process with Many2many fields ('members').
After registration process, a Button (Update Members) showing on Form view.
When clicking this button appears a wizard window where registered members are showing.
Here i need to delete some members ( from listed members on wizard) and click on ApplyChanges button for changes (calling custom function - ApplyChanges). And atlast changes will be applied on main Registrations model.how can i do this??



incoming_member_ids = fields.Many2many("members", String='Incoming Members')


outgoing_member_ids = fields.Many2many("members", String='Outgoing Members')



### incoming members list
if x.action_type == 'incoming_members':
for incoming_partner in x.incoming_members_ids:
incoming_member_ids.append(incoming_member.id)
if not incoming_member_ids:
continue
self.env['registered.members'].create({
'member_ids': incoming_member_ids[0],
})
incoming_member_ids.remove(incoming_member_ids[0])
return True
### Outgoing members list
elif x.action_type == 'outgoing_members':
for outgoinging_member in res.outgoing_member_ids:
outgoing_member_ids.append(outgoinging_member.id)
if not outgoing_member_ids:
continue
self.env['registered.members'].create({
'member_ids': outgoing_member_ids[0],
})
outgoing_member_ids.remove(outgoing_member_ids[0])
return True









share|improve this question

























  • What have you tried so far?

    – CZoellner
    Jan 18 at 8:16











  • Mentioned above my tried code

    – majid
    Jan 18 at 17:35











  • Please format your code properly

    – yorodm
    Jan 18 at 18:21











  • Check at odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

    – WaKo
    Jan 21 at 13:35
















1















I have two views :
1. Registration form view
2 Update Registration Wizard view.
Models :
1 Registration
2 Members



I am setting up a registration process with Many2many fields ('members').
After registration process, a Button (Update Members) showing on Form view.
When clicking this button appears a wizard window where registered members are showing.
Here i need to delete some members ( from listed members on wizard) and click on ApplyChanges button for changes (calling custom function - ApplyChanges). And atlast changes will be applied on main Registrations model.how can i do this??



incoming_member_ids = fields.Many2many("members", String='Incoming Members')


outgoing_member_ids = fields.Many2many("members", String='Outgoing Members')



### incoming members list
if x.action_type == 'incoming_members':
for incoming_partner in x.incoming_members_ids:
incoming_member_ids.append(incoming_member.id)
if not incoming_member_ids:
continue
self.env['registered.members'].create({
'member_ids': incoming_member_ids[0],
})
incoming_member_ids.remove(incoming_member_ids[0])
return True
### Outgoing members list
elif x.action_type == 'outgoing_members':
for outgoinging_member in res.outgoing_member_ids:
outgoing_member_ids.append(outgoinging_member.id)
if not outgoing_member_ids:
continue
self.env['registered.members'].create({
'member_ids': outgoing_member_ids[0],
})
outgoing_member_ids.remove(outgoing_member_ids[0])
return True









share|improve this question

























  • What have you tried so far?

    – CZoellner
    Jan 18 at 8:16











  • Mentioned above my tried code

    – majid
    Jan 18 at 17:35











  • Please format your code properly

    – yorodm
    Jan 18 at 18:21











  • Check at odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

    – WaKo
    Jan 21 at 13:35














1












1








1








I have two views :
1. Registration form view
2 Update Registration Wizard view.
Models :
1 Registration
2 Members



I am setting up a registration process with Many2many fields ('members').
After registration process, a Button (Update Members) showing on Form view.
When clicking this button appears a wizard window where registered members are showing.
Here i need to delete some members ( from listed members on wizard) and click on ApplyChanges button for changes (calling custom function - ApplyChanges). And atlast changes will be applied on main Registrations model.how can i do this??



incoming_member_ids = fields.Many2many("members", String='Incoming Members')


outgoing_member_ids = fields.Many2many("members", String='Outgoing Members')



### incoming members list
if x.action_type == 'incoming_members':
for incoming_partner in x.incoming_members_ids:
incoming_member_ids.append(incoming_member.id)
if not incoming_member_ids:
continue
self.env['registered.members'].create({
'member_ids': incoming_member_ids[0],
})
incoming_member_ids.remove(incoming_member_ids[0])
return True
### Outgoing members list
elif x.action_type == 'outgoing_members':
for outgoinging_member in res.outgoing_member_ids:
outgoing_member_ids.append(outgoinging_member.id)
if not outgoing_member_ids:
continue
self.env['registered.members'].create({
'member_ids': outgoing_member_ids[0],
})
outgoing_member_ids.remove(outgoing_member_ids[0])
return True









share|improve this question
















I have two views :
1. Registration form view
2 Update Registration Wizard view.
Models :
1 Registration
2 Members



I am setting up a registration process with Many2many fields ('members').
After registration process, a Button (Update Members) showing on Form view.
When clicking this button appears a wizard window where registered members are showing.
Here i need to delete some members ( from listed members on wizard) and click on ApplyChanges button for changes (calling custom function - ApplyChanges). And atlast changes will be applied on main Registrations model.how can i do this??



incoming_member_ids = fields.Many2many("members", String='Incoming Members')


outgoing_member_ids = fields.Many2many("members", String='Outgoing Members')



### incoming members list
if x.action_type == 'incoming_members':
for incoming_partner in x.incoming_members_ids:
incoming_member_ids.append(incoming_member.id)
if not incoming_member_ids:
continue
self.env['registered.members'].create({
'member_ids': incoming_member_ids[0],
})
incoming_member_ids.remove(incoming_member_ids[0])
return True
### Outgoing members list
elif x.action_type == 'outgoing_members':
for outgoinging_member in res.outgoing_member_ids:
outgoing_member_ids.append(outgoinging_member.id)
if not outgoing_member_ids:
continue
self.env['registered.members'].create({
'member_ids': outgoing_member_ids[0],
})
outgoing_member_ids.remove(outgoing_member_ids[0])
return True






python postgresql odoo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 18 at 19:00







majid

















asked Jan 17 at 19:26









majidmajid

10811




10811













  • What have you tried so far?

    – CZoellner
    Jan 18 at 8:16











  • Mentioned above my tried code

    – majid
    Jan 18 at 17:35











  • Please format your code properly

    – yorodm
    Jan 18 at 18:21











  • Check at odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

    – WaKo
    Jan 21 at 13:35



















  • What have you tried so far?

    – CZoellner
    Jan 18 at 8:16











  • Mentioned above my tried code

    – majid
    Jan 18 at 17:35











  • Please format your code properly

    – yorodm
    Jan 18 at 18:21











  • Check at odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

    – WaKo
    Jan 21 at 13:35

















What have you tried so far?

– CZoellner
Jan 18 at 8:16





What have you tried so far?

– CZoellner
Jan 18 at 8:16













Mentioned above my tried code

– majid
Jan 18 at 17:35





Mentioned above my tried code

– majid
Jan 18 at 17:35













Please format your code properly

– yorodm
Jan 18 at 18:21





Please format your code properly

– yorodm
Jan 18 at 18:21













Check at odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

– WaKo
Jan 21 at 13:35





Check at odoo-development.readthedocs.io/en/latest/dev/py/x2many.html

– WaKo
Jan 21 at 13:35












1 Answer
1






active

oldest

votes


















0














To remove relation of a particular id from a man2many field, you have to use odoo provided notation on the field. Let's suppose recordset you want perform operation on is records, man2many field is outgoing_member_ids, id you want to remove from that relation is outgoing_member_ids[0], you have to write:



records.write({'outgoing_member_ids': [(3, outgoing_member_ids[0])]})





share|improve this answer
























  • Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

    – majid
    Jan 21 at 13:50











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54242962%2fhow-to-remove-data-from-many2many-field-via-custom-method-in-wizard-in-odoo-10%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














To remove relation of a particular id from a man2many field, you have to use odoo provided notation on the field. Let's suppose recordset you want perform operation on is records, man2many field is outgoing_member_ids, id you want to remove from that relation is outgoing_member_ids[0], you have to write:



records.write({'outgoing_member_ids': [(3, outgoing_member_ids[0])]})





share|improve this answer
























  • Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

    – majid
    Jan 21 at 13:50
















0














To remove relation of a particular id from a man2many field, you have to use odoo provided notation on the field. Let's suppose recordset you want perform operation on is records, man2many field is outgoing_member_ids, id you want to remove from that relation is outgoing_member_ids[0], you have to write:



records.write({'outgoing_member_ids': [(3, outgoing_member_ids[0])]})





share|improve this answer
























  • Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

    – majid
    Jan 21 at 13:50














0












0








0







To remove relation of a particular id from a man2many field, you have to use odoo provided notation on the field. Let's suppose recordset you want perform operation on is records, man2many field is outgoing_member_ids, id you want to remove from that relation is outgoing_member_ids[0], you have to write:



records.write({'outgoing_member_ids': [(3, outgoing_member_ids[0])]})





share|improve this answer













To remove relation of a particular id from a man2many field, you have to use odoo provided notation on the field. Let's suppose recordset you want perform operation on is records, man2many field is outgoing_member_ids, id you want to remove from that relation is outgoing_member_ids[0], you have to write:



records.write({'outgoing_member_ids': [(3, outgoing_member_ids[0])]})






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 19 at 8:55









arrypharryph

53127




53127













  • Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

    – majid
    Jan 21 at 13:50



















  • Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

    – majid
    Jan 21 at 13:50

















Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

– majid
Jan 21 at 13:50





Actually i am having three models and one wizard model as i mentioned. 1 Registration 2. Members 3 .RegisteredMembers 4 . ActionWizard ActionWizard Transient model having: registered_member_ids = Many2many('registered.members') outgoing_member_id = Many2many('registered.members') i want to remove records of via outgoing_member_id of registered_member_id linked to registered.members model.

– majid
Jan 21 at 13:50


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54242962%2fhow-to-remove-data-from-many2many-field-via-custom-method-in-wizard-in-odoo-10%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Liquibase includeAll doesn't find base path

How to use setInterval in EJS file?

Petrus Granier-Deferre