use attribute force_save="1" in view to save value of readonly field.
<field name="payment_type" readonly="1" force_save="1"/>
it will save value of payment_type field when onchange trigger.
@api.model | |
def default_get(self, fields): | |
res = super(PresentationWizard, self).default_get(fields) | |
crm_lead_id = self.env.context.get('active_id') | |
crm_lead = self.env['crm.lead'].browse(crm_lead_id) | |
if 'attachment_doc' in fields: | |
res.update({'attachment_doc': crm_lead.file_prospect}) | |
return res |
use attribute force_save="1" in view to save value of readonly field.
<field name="payment_type" readonly="1" force_save="1"/>
it will save value of payment_type field when onchange trigger.
dict(self._fields['your_field'].selection).get(self.your_field) |
... | |
date_tz = fields.Selection('_tz_get', string='Timezone', required=True, | |
default=lambda self: self.env.user.tz or 'UTC') | |
@api.model | |
def _tz_get(self): | |
return [(x, x) for x in pytz.all_timezones] | |
... |
SELECT table_name | |
FROM information_schema.tables | |
WHERE table_schema = 'database_name' | |
ORDER BY table_name ASC; |
[('x_partners','=',parent.partner_id)]
<field name="journal_ids" context="{'tree_view_ref':'module_name.my_joural_tree_view'}" />
(0, 0, { values }) link to a new record that needs to be created with the given values dictionary
(1, ID, { values }) update the linked record with id = ID (write *values* on it)
(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
(4, ID) link to existing record with id = ID (adds a relationship)
(4, [ID]) link to existing record with id = ID (adds a relationship)
(5) unlink all (like using (3,ID) for all linked records)
(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)
(5, 0, 0) unlink all
Run from Terminal:
python3 odoo-bin shell -d mydb --addons-path=/your/addons/path
Run from python console:
self.env['ir.module.module'].search([('name', '=', 'crm')]).button_immediate_uninstall()
class ModelA(models.Model): | |
_name = "model.a" | |
alias_contact = fields.Selection([ | |
('everyone', 'Everyone'), | |
('partners', 'Authenticated Partners'), | |
('followers', 'Followers only')], default='everyone', | |
string='Alias Contact Security', required=True, | |
help="Policy to post a message on the document using the mailgateway.\n" | |
"- everyone: everyone can post\n" |