from odoo.addons.website.controllers.main import Website
class MyTranslit(Website):
<ls user="http" />.route('/website/translations', type='json', auth="public", website=True)
def get_website_translations(self, lang, mods=None):
return Website().get_website_translations(lang,список наименований ваших приложений)
def _my_funct(self):
if self.fields1==1:
id=self.env['child'].sudo().search([('fields2,'=',self.fields1)],limit=1).id # получаем id child по условию parent
return [('id','=',id)]
<xpath expr="//input[<ls user="name" />='company_name']/.." position="attributes">
<attribute name="style">display: none</attribute>
</xpath>
<xpath expr="//input[<ls user="name" />='vat']/.." position="attributes">
<attribute name="style">display: none</attribute>
</xpath>
<xpath expr="//input[<ls user="name" />='street']/.." position="attributes">
<attribute name="style">display: none</attribute>
</xpath>
<div class="oe_search">
<input type="text" name="search" class="form-control js_website_autocomplete" placeholder="Выберите откуда" t-att-value="startst"
data-query-field="name" /// поле модели по которому ищем
data-display-field="name" /// получаемое поле в ниспадающий список
data-value-field="name" /// возвращаемое поле модели
data-limit="10"
data-model="test.test" /// имя модели
/>
</div>
<script type="text/javascript" src="/web/static/lib/jquery.ui/jquery-ui.js"></script>
<script type="text/javascript" src="/web/static/lib/jquery.ui/jquery.ui.autocomplete.html.js"></script>
$.widget( "ui.autocomplete", {
version: "1.11.4",
defaultElement: "<input>",
options: {
appendTo: null,
autoFocus: false,
delay: 300,
minLength: 1,
position: {
my: "left top",
at: "left bottom",
collision: "none"
},
source: null,
html:true,
// callbacks
change: null,
close: null,
focus: null,
open: null,
response: null,
search: null,
select: null
},
<template id="search" name="Форма поиска">
<t t-set="startst" t-value="bool(listst['startst']>0)"/>
<t t-set="endst" t-value="bool(listst['endst']>0)"/>
<div id="wrap" class="search_snippet">
<input type="hidden" name="tk"/>
<div class="snippet" >
<section class="s_text_block_image_fw oe_img_bg oe_custom_bg" style="background-image: url(/website/static/src/img/390.jpg); background-position: 12.57% 8.07%;">
<div class="container">
<div class="row">
<div class="col-md-6 mt64 mb64 bg-black-25">
<p class="o_default_snippet_text text-center">Пример записи</p>
</div>
</div>
</section>
</div>
</div>
</template
<input type="hidden" name="tk"/>
<div class="snippet" >
odoo.define('test.find', function (require) {
'use strict';
var animation = require('web_editor.snippets.animation');
animation.registry.search_snippet = animation.Class.extend({
selector: ".search_snippet",
start: function(editable_mode) {
var el=this.$target.find(".snippet");
var tid=this.$target.find("input[name*='tk']" )
el.addClass('oe_structure o_editable o_dirty note-air-editor note-editable');
el.attr('data-oe-model','ir.ui.view');
el.attr('data-oe-id',tid.attr('data-oe-id'));
el.attr('data-oe-xpath',"/t[1]/div[1]/div[1]");
if (editable_mode) {
//
}
else {
// this.$target.find(".snippet").removeClass('oe_structure o_editable o_dirty note-air-editor note-editable');
}
},
error: function(data){
},
});
class Table(models.Model):
_name = "my.table"
name = fields.Char("Наименование", required=True)
_parent_store = True
parent_id = fields.Many2one('my.table', 'ID Родителя', ondelete='restrict')
def create_recors(self):
table = self.env['my.table']
#table.create({"name": "testname", "parent_id": "False"})
<record model="ir.ui.view" id="test_tree_view">
<field name="name">test.tree</field>
<field name="model">test.test</field>
<field name="arch" type="xml">
<tree string="This test" class="test_tree">
<field name="name"/>
<field name="test1"/>
<field name="test2"/>
</tree>
</field>
</record>
.test_tree table{
width: 70%;
}
.test_tree th[data-id='name']{
width: 40%;
}
.test_tree th[data-id='test1']{
width: 4%;
}
.test_tree th[data-id='test2']{
width: 10%;
}
def find_in_path(name):
odoo-bin start
. При запуске сообщение об ошибкеModuleNotFoundError: No module named 'loglevels'
<template id="product_info" name="Product Info">
<div id="modal_optional_products" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" style="width:350px;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h4 class="modal-title" id="myModalLabel"><t t-esc="product"/>
<t t-esc="product"/></br></h4>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
Код страницы
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<a name="info_route" itemprop="name" t-att-route="slug(product)" class="btn btn-primary btn-lg">Инфо</a></span>
$('a[name="info_route"]')
.off('click')
.removeClass('a-submit')
.click(function (event) {
var product_id = parseInt($(this).attr('route'));
event.preventDefault();
ajax.jsonRpc("/shop/info", 'call', {
'product_id': product_id,
}).then(function (modal) {
var $modal = $(modal);
$modal
.modal()
.on('hidden.bs.modal', function () {
$(this).remove();
});
});
return false;
});
request.session['test1']='a'
request.session['test2']='b'
v={}
v={'start':1,'end':2,'name':'test'}
request.session['v']=v
a=request.session['test1']
b=request.session['test2']
v=request.session['v']
v.pop('start')
<xpath expr="//field[<ls user="name" />='description']" position="after">
<field name="idea_ids" />
</xpath>
<field name="description" position="after">
<field name="idea_ids" />
</field>
<record>
Например:<record model="ir.actions.act_window.view" id="action_crm_tag_kanban_view_oppor11">
<field name="sequence" eval="0"/>
<field name="view_mode">kanban</field>
<field name="view_id" ref="crm_case_kanban_view_leads"/>
<field name="act_window_id" ref="crm_lead_opportunities"/>
</record>
???<div>
<button string="Return data" name="return_record_data" type="button">Return data </button>
</div>