mirror of https://github.com/OCA/web.git
commit
b2c17a1048
|
@ -31,21 +31,14 @@ class BaseModel(models.BaseModel):
|
|||
field_obj = self[relation_field]
|
||||
if field_obj:
|
||||
relation_id = relation_id.id
|
||||
has_product = (
|
||||
self.search(
|
||||
[
|
||||
(relation_field, "=", relation_id),
|
||||
(product_field, "in", product_ids),
|
||||
],
|
||||
count=True,
|
||||
db_sol = self.search(
|
||||
[(relation_field, "=", relation_id), (product_field, "in", product_ids)],
|
||||
limit=1,
|
||||
)
|
||||
!= 0
|
||||
)
|
||||
if has_product:
|
||||
if db_sol:
|
||||
raise ValidationError(
|
||||
_("Can't create the %s: Duplicated product! (Already in database)")
|
||||
% relation
|
||||
_("Can't create the %s: Duplicated product (%s)! (Already in database)")
|
||||
% (relation, db_sol[product_field].display_name)
|
||||
)
|
||||
|
||||
@api.model_create_multi
|
||||
|
|
|
@ -98,6 +98,9 @@ odoo.define(
|
|||
},
|
||||
|
||||
canBeUpdated: function() {
|
||||
if (!this.getParent()) {
|
||||
return false;
|
||||
}
|
||||
var model = this.getParent().getBasicFieldParams().model;
|
||||
for (var widget of this.widgets) {
|
||||
if (!widget.state) {
|
||||
|
@ -149,6 +152,9 @@ odoo.define(
|
|||
},
|
||||
|
||||
getWidgetsWithoutOnchange: function() {
|
||||
if (!this.getParent()) {
|
||||
return false;
|
||||
}
|
||||
var model = this.getParent().getBasicFieldParams().model;
|
||||
return _.filter(this.widgets, function(item) {
|
||||
return (
|
||||
|
|
|
@ -810,6 +810,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
|||
_saveDocument: function(ids_to_update) {
|
||||
var widgets = this.renderer.getWidgetsWithoutOnchange();
|
||||
if (
|
||||
widgets === false ||
|
||||
!_.isEmpty(this._ids_to_wait) ||
|
||||
_.isEmpty(ids_to_update) ||
|
||||
!_.isEmpty(widgets)
|
||||
|
@ -1140,6 +1141,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
|||
_onResumeAutoSave: function() {
|
||||
// Check if can resume
|
||||
if (
|
||||
!this._is_auto_save_paused ||
|
||||
this.$(".oe_product_picker_quick_modif_price").is(":visible") ||
|
||||
this.$(".oe_search_input").is(":focus") ||
|
||||
this.$(".oe_flip_card.active").length
|
||||
|
@ -1148,6 +1150,9 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
|
|||
}
|
||||
|
||||
if (this._need_resume_auto_save) {
|
||||
if (this._auto_save_timeout) {
|
||||
clearTimeout(this._auto_save_timeout);
|
||||
}
|
||||
this._auto_save_timeout = setTimeout(
|
||||
this._saveDocument.bind(this),
|
||||
this.options.auto_save_delay,
|
||||
|
|
Loading…
Reference in New Issue