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
import hashlib | |
plaintext = "hello".encode() | |
d = hashlib.sha256(plaintext) | |
# generate binary hash of "hello" string | |
hash = d.digest() | |
print(hash) | |
# generate human readable hash of "hello" string |
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
from odoo import fields, models | |
class Property(models.Model): | |
_name = "realtor.property" | |
_description = "Real Estate Property" | |
name = fields.Char(required=True) | |
manager_id = fields.Many2one( | |
comodel_name="realtor.property.manager", string="Manager", required=True |
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
from odoo import fields, models | |
class Property(models.Model): | |
_name = "realtor.property" | |
_description = "Real Estate Property" | |
name = fields.Char(required=True) | |
manager_id = fields.Many2one( | |
comodel_name="realtor.property.manager", string="Manager", required=True | |
) |
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
<odoo> | |
<data> | |
<record id="interested_property_template" model="mail.template"> | |
<field name="name">Realtor: I'm Intersted In Property</field> | |
<field name="model_id" ref="model_realtor_property" /> | |
<field name="body_html" type="html"> | |
<div> | |
<p>Hello <strong>--property-manager-name--</strong>,</p> | |
<p>An individual has shown interest in your property <strong>--property-name--</strong>.</p> |
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
<odoo> | |
<data> | |
<record id="interested_property_template" model="mail.template"> | |
<field name="name">Realtor: I'm Intersted In Property</field> | |
<field name="model_id" ref="model_realtor_property" /> | |
<field name="subject">Someone's Interested in Your Property</field> | |
<field name="email_from">ofelix03@gmail.com</field> | |
<field name="email_to">${object.env.user.email}</field> | |
<field name="body_html" type="html"> | |
<div> |
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.model | |
def create(self, vals): | |
try: | |
# if user has right permission, continue with create operation | |
return super(Customer, self).create(vals) | |
except AccessError: | |
raise ValidationError(_("Sorry! you don't have the right permission to create this record")) | |
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
from odoo import models | |
class SomeModel(models.Model): | |
_name = 'some.model' | |
# Defines the field used to to store records archive state | |
# Odoo supports only two fields for archiving and unarchiving records, active and x_active field | |
_active_name = 'x_active' | |
def action_archive_method(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
select *, ( | |
select concat(date, ' ', time) "last_visited" from site_visits | |
where user_id = u.id | |
order by id desc | |
limit 1 | |
) "last_visited" | |
from users u |
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
select u.*, last_visited | |
from users u, | |
lateral( | |
select concat(date, ' ', time) "last_visited" from site_visits | |
where user_id = u.id | |
order by id desc | |
limit 1 | |
) last_visited | |
where u.email = 'myuryichev2@guardian.co.uk' |
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.model | |
def create(self, vals): | |
if not self.check_access_rights('create', raise_exception=False): | |
raise ValidationError(_("Sorry! you don't have the right permission to create this record")) | |
# user has right permission, continue with operation | |
return super(Customer, self).create(vals) | |
NewerOlder