Merge PR #2185 into 13.0

Signed-off-by pedrobaeza
pull/2210/head
OCA-git-bot 2022-05-04 21:37:13 +00:00
commit b2c17a1048
3 changed files with 17 additions and 13 deletions

View File

@ -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,
limit=1,
)
!= 0
db_sol = self.search(
[(relation_field, "=", relation_id), (product_field, "in", product_ids)],
limit=1,
)
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

View File

@ -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 (

View File

@ -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,