Skip to content

Commit

Permalink
return assembled domain instead write it in object
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Nechyporenko committed Jul 20, 2023
1 parent 28ca387 commit 9cd719a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crnd_web_field_domain/static/src/js/basic_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ odoo.define('crnd_web_field_domain.field_domain', function (require) {
var BasicModel = require('web.BasicModel');
var pyUtils = require("web.py_utils");
var assembleDomains = pyUtils.assembleDomains;
var Domain = require('web.Domain');


BasicModel.include({

init: function () {
this.assembleDomains = pyUtils.assembleDomains;
this.Domain = Domain;
this._super.apply(this, arguments);
this.originDomain;
},

_getDomain: function (element, options) {
Expand All @@ -27,23 +30,20 @@ odoo.define('crnd_web_field_domain.field_domain', function (require) {
if (element._domains[options.fieldName]) {
var origin_domain = element._domains[options.fieldName].length !== 0 ? element._domains[options.fieldName] : "[]";
var assembled_domain = this.assembleDomains([origin_domain, domain_field_value], "AND");
element._domains[options.fieldName] = assembled_domain;
return this._super.apply(this, arguments);
return Domain.prototype.stringToArray(assembled_domain, this._getEvalContext(element, true));
}
var viewType = options.viewType || element.viewType;
var fieldInfo = element.fieldsInfo[viewType][options.fieldName];
if (fieldInfo && fieldInfo.domain) {
var origin_domain = fieldInfo.domain.length !== 0 ? fieldInfo.domain : "[]";
var assembled_domain = this.assembleDomains([origin_domain, domain_field_value], "AND");
element.fieldsInfo[viewType][options.fieldName].domain = assembled_domain;
return this._super.apply(this, arguments);
return Domain.prototype.stringToArray(assembled_domain, this._getEvalContext(element, true));
}
var fieldParams = element.fields[options.fieldName];
if (fieldParams.domain) {
var origin_domain = fieldParams.domain.length !== 0 ? fieldParams.domain : "[]";
var assembled_domain = this.assembleDomains([origin_domain, domain_field_value], "AND");
element.fields[options.fieldName].domain = assembled_domain;
return this._super.apply(this, arguments);
return Domain.prototype.stringToArray(assembled_domain, this._getEvalContext(element, true));
}
return this._super.apply(this, arguments);
}
Expand Down

0 comments on commit 9cd719a

Please sign in to comment.