Skip to content

Commit

Permalink
⚡ default record for existing models in reference field
Browse files Browse the repository at this point in the history
  • Loading branch information
KolushovAlexandr committed Sep 18, 2018
1 parent 6385c02 commit 771b568
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions base_details/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
],
"external_dependencies": {"python": [], "bin": []},
"data": [
'views/assets.xml'
],
"qweb": [
],
Expand Down
1 change: 1 addition & 0 deletions base_details/models/base_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def details(self):
def onchange_details_model(self):
if self.details_model and self.details_model in [x.model for x in self.env['ir.model'].search([])]:
self.details_model_exists = True
self.details_model_record = self.env[self.details_model].search([], limit=1)
else:
self.details_model_exists = False

Expand Down
13 changes: 13 additions & 0 deletions base_details/static/src/js/FieldReference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
odoo.define('base_details', function(require) {
'use strict';

var FieldReference = require('web.relational_fields').FieldReference;

var FieldReference = FieldReference.include({
_reset: function () {
this._super.apply(this, arguments);
this._setState();
},
});

});
10 changes: 10 additions & 0 deletions base_details/views/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -->
<odoo>
<template id="assets_backend" name="base_details_assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/base_details/static/src/js/FieldReference.js"></script>
</xpath>
</template>
</odoo>

0 comments on commit 771b568

Please sign in to comment.