This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base_url = self.env['ir.config_parameter'].get_param('web.base.url') | |
if not 'localhost' in base_url: | |
if 'http://' in base_url: | |
base_url = base_url.replace('http://', 'https://') | |
base_url = base_url + '/web#id=' + str(self.id) + '&model=your.model.goes.here&view_type=form&cids=' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class res_company(models.Model): | |
_inherit = 'res.company' | |
@api.multi | |
def generate_qr(self, txt=''): | |
qr_code = qrcode.QRCode(version=4, box_size=4, border=1) | |
qr_code.add_data(txt) | |
qr_code.make(fit=True) | |
qr_img = qr_code.make_image() | |
im = qr_img._img.convert("RGB") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cmd_send_notification(self): | |
action = self.env.ref('module_name.id_of_custom_action_window') | |
return { | |
'type': 'ir.actions.client', | |
'tag': 'display_notification', | |
'params': { | |
'title': _('Your Custom Notification Title'), | |
'message': '%s', | |
'links': [{ | |
'label': self.customer_id.name, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cmd_send_notification(self): | |
return { | |
'type': 'ir.actions.client', | |
'tag': 'display_notification', | |
'params': { | |
'title': _('Your Custom Notification Title'), | |
'message': 'Your Custom Message...', | |
'sticky': False, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class some_model(models.Model): | |
_name = "some.model" | |
STATES = [('Draft','Draft'),('Submit','Submit'),('Closed','Closed')] | |
# States that should be folded in Kanban view | |
# used by the `state_groups` method | |
FOLDED_STATES = [ | |
'Closed', | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@api.onchange('field_1','field_2','field_3','field_4','field_5') | |
def onchange_of_fields(self): | |
res={} | |
res['domain'] = {'many2many_field': []} | |
for each in self: | |
if each.field_1: | |
res['domain']['many2many_field'].append(('field_1', '=', each.field_1.id)) | |
if each.field_2: | |
res['domain']['many2many_field'].append(('field_2', '=', each.field_2.id)) | |
if each.field_3: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class gym_body_parts_config(models.Model): | |
_name = 'gym.body.parts.config' | |
sequence = fields.Integer(default=10,help="Gives the sequence order when displaying a list of records.") | |
name = fields.Char(string="Name", required=True) | |
progress_percentpie = fields.Integer(compute='_compute_progress_percentpie') | |
@api.depends('name','sequence') | |
def _compute_progress_percentpie(self): | |
for u in self: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class gym_body_parts_config(models.Model): | |
_name = 'gym.body.parts.config' | |
sequence = fields.Integer(default=10,help="Gives the sequence order when displaying a list of records.") | |
name = fields.Char(string="Name", required=True) | |
progress_gauge = fields.Integer(compute='_compute_progress_gauge') | |
@api.depends('name','sequence') | |
def _compute_progress_gauge(self): | |
for u in self: |
NewerOlder