mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[FIX] web_widget_one2many_product_picker_sale_secondary_unit: Secondary unit management
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
"version": "13.0.1.0.0",
|
||||
"category": "Website",
|
||||
"author": "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"website": "https://www.tecnativa.com",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["web_widget_one2many_product_picker", "sale_order_secondary_unit"],
|
||||
"data": ["templates/assets.xml"],
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
// Copyright 2021 Tecnativa - Alexandre Díaz
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define("web_widget_one2many_product_picker_sale_secondary_unit.One2ManyProductPickerRecord", function(
|
||||
require
|
||||
) {
|
||||
"use strict";
|
||||
odoo.define(
|
||||
"web_widget_one2many_product_picker_sale_secondary_unit.One2ManyProductPickerRecord",
|
||||
function(require) {
|
||||
"use strict";
|
||||
|
||||
const One2ManyProductPickerRecord = require("web_widget_one2many_product_picker.One2ManyProductPickerRecord");
|
||||
const One2ManyProductPickerRecord = require("web_widget_one2many_product_picker.One2ManyProductPickerRecord");
|
||||
|
||||
One2ManyProductPickerRecord.include({
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_setMasterUomMap: function () {
|
||||
this._super.apply(this, arguments);
|
||||
if ((this.state && this.state.data && this.state.data.secondary_uom_id) ||
|
||||
!this.state && this.recordSearch && this.recordSearch.sale_secondary_uom_id) {
|
||||
_.extend(this.master_uom_map, {
|
||||
"field_uom": "secondary_uom",
|
||||
"field_uom_qty": "secondary_uom_qty",
|
||||
"search_field_uom": "sale_secondary_uom_id",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
One2ManyProductPickerRecord.include({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_setMasterUomMap: function() {
|
||||
this._super.apply(this, arguments);
|
||||
if (
|
||||
(this.state &&
|
||||
this.state.data &&
|
||||
this.state.data.secondary_uom_id) ||
|
||||
(!this.state &&
|
||||
this.recordSearch &&
|
||||
this.recordSearch.sale_secondary_uom_id)
|
||||
) {
|
||||
_.extend(this.master_uom_map, {
|
||||
field_uom: "secondary_uom",
|
||||
field_uom_qty: "secondary_uom_qty",
|
||||
search_field_uom: "sale_secondary_uom_id",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -11,9 +11,11 @@ odoo.define(
|
||||
_isEqualState: function(state_a, state_b) {
|
||||
const res = this._super.apply(this, arguments);
|
||||
const secondary_uom_id_a =
|
||||
state_a.data.secondary_uom_id && state_a.data.secondary_uom_id.data.id;
|
||||
state_a.data.secondary_uom_id &&
|
||||
state_a.data.secondary_uom_id.data.id;
|
||||
const secondary_uom_id_b =
|
||||
state_b.data.secondary_uom_id && state_b.data.secondary_uom_id.data.id;
|
||||
state_b.data.secondary_uom_id &&
|
||||
state_b.data.secondary_uom_id.data.id;
|
||||
return res && secondary_uom_id_a === secondary_uom_id_b;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
// Copyright 2021 Tecnativa - Alexandre Díaz
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define("web_widget_one2many_product_picker_sale_secondary_unit.FieldOne2ManyProductPicker", function(
|
||||
require
|
||||
) {
|
||||
"use strict";
|
||||
odoo.define(
|
||||
"web_widget_one2many_product_picker_sale_secondary_unit.FieldOne2ManyProductPicker",
|
||||
function(require) {
|
||||
"use strict";
|
||||
|
||||
const FieldOne2ManyProductPicker = require("web_widget_one2many_product_picker.FieldOne2ManyProductPicker");
|
||||
const FieldOne2ManyProductPicker = require("web_widget_one2many_product_picker.FieldOne2ManyProductPicker");
|
||||
|
||||
FieldOne2ManyProductPicker.include({
|
||||
// Model product.product fields
|
||||
search_read_fields: _.unique([].concat(FieldOne2ManyProductPicker.prototype.search_read_fields, [
|
||||
"sale_secondary_uom_id",
|
||||
])),
|
||||
FieldOne2ManyProductPicker.include({
|
||||
// Model product.product fields
|
||||
search_read_fields: _.unique(
|
||||
[].concat(FieldOne2ManyProductPicker.prototype.search_read_fields, [
|
||||
"sale_secondary_uom_id",
|
||||
])
|
||||
),
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @returns {Object}
|
||||
*/
|
||||
_getDefaultOptions: function() {
|
||||
const res = this._super.apply(this, arguments);
|
||||
res.field_map.secondary_uom = "secondary_uom_id";
|
||||
res.field_map.secondary_uom_qty = "secondary_uom_qty";
|
||||
return res;
|
||||
},
|
||||
});
|
||||
});
|
||||
/**
|
||||
* @private
|
||||
* @returns {Object}
|
||||
*/
|
||||
_getDefaultOptions: function() {
|
||||
const res = this._super.apply(this, arguments);
|
||||
res.field_map.secondary_uom = "secondary_uom_id";
|
||||
res.field_map.secondary_uom_qty = "secondary_uom_qty";
|
||||
return res;
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<template>
|
||||
|
||||
<t t-extend="One2ManyProductPicker.FlipCard.Front">
|
||||
<t
|
||||
t-jquery="t[t-call='One2ManyProductPicker.ActionButton']"
|
||||
@@ -11,7 +10,7 @@
|
||||
>
|
||||
<span
|
||||
t-att-data-field="field_map[field_uom_qty]"
|
||||
t-attf-data-esc="str({{field_map.product_uom_qty}}) + ' x ' + {{field_map.product_uom}}.data.display_name"
|
||||
t-attf-data-esc="'{{floatFixed(field_map.product_uom_qty)}}' + ' x ' + {{field_map.product_uom}}.data.display_name"
|
||||
class="badge badge-primary mw-100 text-truncate overflow-hidden d-inline-block float-left font-weight-bold rounded-0 m-0 p-2"
|
||||
/>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user