How to remove data from Many2many field via custom method in wizard in odoo 10?
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
add a comment |
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
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
add a comment |
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
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
python postgresql odoo
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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])]})
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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])]})
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
add a comment |
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])]})
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
add a comment |
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])]})
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])]})
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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