Browse Source

pre-commit

myc-14.0-py3o
Andrea 4 years ago
parent
commit
57aee07bc0
  1. 6
      bi_view_editor/models/bve_view.py
  2. 12
      bi_view_editor/models/bve_view_line.py
  3. 9
      bi_view_editor/models/ir_model.py
  4. 6
      bi_view_editor/security/rules.xml
  5. 4
      bi_view_editor/static/src/js/bi_view_editor.FieldList.js
  6. 4
      bi_view_editor/static/src/js/bi_view_editor.ModelList.js
  7. 13
      bi_view_editor/static/src/xml/bi_view_editor.xml

6
bi_view_editor/models/bve_view.py

@ -320,7 +320,11 @@ class BveView(models.Model):
try: try:
with self.env.cr.savepoint(): with self.env.cr.savepoint():
self.env.cr.execute( self.env.cr.execute(
"CREATE or REPLACE VIEW %s as (%s)", (AsIs(view_name), AsIs(query),)
"CREATE or REPLACE VIEW %s as (%s)",
(
AsIs(view_name),
AsIs(query),
),
) )
except Exception as e: except Exception as e:
raise UserError( raise UserError(

12
bi_view_editor/models/bve_view_line.py

@ -57,8 +57,16 @@ class BveViewLine(models.Model):
def _constrains_unique_fields_check(self): def _constrains_unique_fields_check(self):
seen = set() seen = set()
for line in self.mapped("bve_view_id.field_ids"): for line in self.mapped("bve_view_id.field_ids"):
if (line.table_alias, line.field_id.id,) not in seen:
seen.add((line.table_alias, line.field_id.id,))
if (
line.table_alias,
line.field_id.id,
) not in seen:
seen.add(
(
line.table_alias,
line.field_id.id,
)
)
else: else:
raise ValidationError( raise ValidationError(
_("Field %s/%s is duplicated.\n" "Please remove the duplications.") _("Field %s/%s is duplicated.\n" "Please remove the duplications.")

9
bi_view_editor/models/ir_model.py

@ -85,7 +85,11 @@ class IrModel(models.Model):
for field in fields: for field in fields:
for table_alias in model_table_map[field.model_id.id]: for table_alias in model_table_map[field.model_id.id]:
model_list.append( model_list.append(
dict(dict_for_field(field), table_alias=table_alias, join_node=-1,)
dict(
dict_for_field(field),
table_alias=table_alias,
join_node=-1,
)
) )
return model_list return model_list
@ -133,8 +137,7 @@ class IrModel(models.Model):
@api.model @api.model
def get_models(self, table_model_map=None): def get_models(self, table_model_map=None):
""" Return list of model dicts for all available models.
"""
"""Return list of model dicts for all available models."""
self = self.with_context(lang=self.env.user.lang) self = self.with_context(lang=self.env.user.lang)
model_table_map = defaultdict(list) model_table_map = defaultdict(list)
for k, v in (table_model_map or {}).items(): for k, v in (table_model_map or {}).items():

6
bi_view_editor/security/rules.xml

@ -4,8 +4,8 @@
<field name="name">bve_view read access</field> <field name="name">bve_view read access</field>
<field name="model_id" search="[('model','=','bve.view')]" model="ir.model" /> <field name="model_id" search="[('model','=','bve.view')]" model="ir.model" />
<field name="global" eval="True" /> <field name="global" eval="True" />
<field
name="domain_force"
> ['|',('user_ids','=',False),('user_ids','in',user.id)]</field>
<field name="domain_force">
['|',('user_ids','=',False),('user_ids','in',user.id)]
</field>
</record> </record>
</odoo> </odoo>

4
bi_view_editor/static/src/js/bi_view_editor.FieldList.js

@ -126,9 +126,7 @@ odoo.define("bi_view_editor.FieldList", function(require) {
return $.makeArray( return $.makeArray(
this.$el.find("tbody tr").map(function () { this.$el.find("tbody tr").map(function () {
var field = $(this).data("field"); var field = $(this).data("field");
field.description = $(this)
.find('input[name="description"]')
.val();
field.description = $(this).find('input[name="description"]').val();
return field; return field;
}) })
); );

4
bi_view_editor/static/src/js/bi_view_editor.ModelList.js

@ -122,9 +122,7 @@ odoo.define("bi_view_editor.ModelList", function(require) {
return; return;
} }
var model = $el.data("model"); var model = $el.data("model");
$el.parent()
.find(".field")
.remove();
$el.parent().find(".field").remove();
if (this.isActive(model.id)) { if (this.isActive(model.id)) {
this.removeAsActive(model.id); this.removeAsActive(model.id);
} else { } else {

13
bi_view_editor/static/src/xml/bi_view_editor.xml

@ -4,6 +4,7 @@
<div class="oe_form_field_bi_editor"> <div class="oe_form_field_bi_editor">
<div class="body"> <div class="body">
<div class="left"> <div class="left">
</div> </div>
<div class="right"> <div class="right">
@ -13,9 +14,10 @@
<div class="footer"> <div class="footer">
<div class="left" /> <div class="left" />
<div class="right"> <div class="right">
<button class="clear-btn d-none"><span
class="fa fa-eraser"
/> Clear</button>
<button class="clear-btn d-none">
<span class="fa fa-eraser" />
Clear
</button>
</div> </div>
</div> </div>
</div> </div>
@ -76,6 +78,7 @@
<input type="text" class="search-bar" /> <input type="text" class="search-bar" />
</div> </div>
<div class="class-list"> <div class="class-list">
</div> </div>
</div> </div>
</t> </t>
@ -106,6 +109,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -165,7 +169,8 @@
type="checkbox" type="checkbox"
data-for="join_left" data-for="join_left"
class="checkbox-join-left" class="checkbox-join-left"
/> Join Left
/>
Join Left
</label> </label>
</div> </div>
</li> </li>

Loading…
Cancel
Save