Skip to content

Instantly share code, notes, and snippets.

View tienhieuD's full-sized avatar
🦶
hmmm

DUONG TIEN HIEU tienhieuD

🦶
hmmm
View GitHub Profile
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
@tienhieuD
tienhieuD / config.py
Last active April 13, 2018 15:49
View for config exmalple Odoo
# -*- coding: utf-8 -*-
from odoo import fields, models, api
class Config(models.TransientModel):
_name = 'mylib.config'
_inherit = 'res.config.settings'
_description = 'My Library Config'
@tienhieuD
tienhieuD / rule.xml
Created April 3, 2018 04:56
Demo record rule
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="employee_book_loan_create" model="ir.rule">
<field name="name">Nhân viên chỉ thấy phiếu mượn do mình tạo</field>
<field name="model_id" ref="model_mylib_book_loan"/>
<field name="domain_force">[('create_uid', '=', user.id)]</field>
<field name="perm_write" eval="0"/>
<field name="perm_create" eval="0"/>
# -*- coding: utf-8 -*-
from odoo import fields, models
class TestDomain(models.Model):
_name = 'test.domain'
_description = 'domain test'
_rec_name = 'book'
book = fields.Many2one("mylib.book", 'Sách của tôi', domain=[])
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="domain_act" model="ir.actions.act_window">
<field name="name">Domain test</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">test.domain</field>
<field name="view_mode">form</field>
</record>
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate='1'>
<record id="lost_document_email_templates" model="mail.template">
<field name="name">Mẫu email: Thông báo về thất lạc hồ sơ</field>
<field name="email_from">
${object.partner_id.company_id and object.partner_id.company_id.email or ''}
</field>
<field name="subject">Thông báo về việc thất lạc hồ sơ: ${object.name}
</field>
<field name="email_to">${object.partner_id.email|safe}</field>
#include <iostream>
using namespace std;
void nhapmang(int a[], int n) {
for (int i = 0; i < n; i++) {
cout << "Nhap a[" << i << "]=";
cin >> a[i];
}
}
void xuatmang(int a[], int n) {
@api.model
def create_user(self, name, email, pwd):
info = { 'name': name,
'login': email,
'password': pwd,}
try:
self.env['res.users'].sudo().create(info)
return True
except:
return False
{
"name": "Python: Odoo",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceRoot}/odoo-bin",
"args": [
"--config=../odoo.conf",
],
def get_selection_name(env, model, field, value):
return dict(env[model].fields_get(field, 'selection').get(field, {}).get('selection',{})).get(value)
# usage
get_selection_name(request.env, 'sale.order', 'general_status', 'picking') # 'Đang lấy hàng'
get_selection_name(self.env, 'sale.order', 'general_status', 'picking') # 'Đang lấy hàng'