mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-19 19:12:00 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {BomOverviewComponent} from "@mrp/components/bom_overview/mrp_bom_overview";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(BomOverviewComponent.prototype, "ddmrp", {
|
||||
setup() {
|
||||
this._super.apply();
|
||||
this.state.showOptions.is_buffered = true;
|
||||
this.state.showOptions.dlt = true;
|
||||
},
|
||||
|
||||
async getWarehouses() {
|
||||
await this._super.apply();
|
||||
if (this.props.action.context.warehouse_id) {
|
||||
this.state.currentWarehouse = this.warehouses.filter(
|
||||
(warehouse) => warehouse.id === this.props.action.context.warehouse_id
|
||||
)[0];
|
||||
}
|
||||
},
|
||||
|
||||
getReportName() {
|
||||
return (
|
||||
this._super.apply(this, arguments) +
|
||||
"&show_buffered=" +
|
||||
this.state.showOptions.is_buffered
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {BomOverviewDisplayFilter} from "@mrp/components/bom_overview_display_filter/mrp_bom_overview_display_filter";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(BomOverviewDisplayFilter.prototype, "ddmrp", {
|
||||
setup() {
|
||||
this._super.apply();
|
||||
this.displayOptions.is_buffered = this.env._t("Buffered");
|
||||
},
|
||||
});
|
||||
|
||||
patch(BomOverviewDisplayFilter, "ddmrp", {
|
||||
props: {
|
||||
...BomOverviewDisplayFilter.props,
|
||||
showOptions: {
|
||||
...BomOverviewDisplayFilter.showOptions,
|
||||
is_buffered: Boolean,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {BomOverviewLine} from "@mrp/components/bom_overview_line/mrp_bom_overview_line";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(BomOverviewLine, "ddmrp", {
|
||||
props: {
|
||||
...BomOverviewLine.props,
|
||||
showOptions: {
|
||||
...BomOverviewLine.showOptions,
|
||||
is_buffered: Boolean,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t
|
||||
t-name="ddmrp.BomOverviewLine"
|
||||
t-inherit="mrp.BomOverviewLine"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//td[@name='td_mrp_bom']" position="before">
|
||||
<td
|
||||
t-if="props.showOptions.is_buffered and data.is_buffered"
|
||||
class="text-center"
|
||||
>
|
||||
<span>
|
||||
<img
|
||||
src='/ddmrp/static/img/is_buffered.png'
|
||||
style="width:30px;height:30px;padding:5px"
|
||||
/>
|
||||
</span>
|
||||
</td>
|
||||
<td t-if="props.showOptions.is_buffered and !data.is_buffered" />
|
||||
</xpath>
|
||||
<xpath expr="//td[@t-if='showLeadTimes']" position="after">
|
||||
<td t-if="showLeadTimes" class="text-end">
|
||||
<t
|
||||
t-esc="data.dlt"
|
||||
t-options='{"widget": "float", "decimal_precision": "Lead Time"}'
|
||||
/> Days
|
||||
</td>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {BomOverviewSpecialLine} from "@mrp/components/bom_overview_special_line/mrp_bom_overview_special_line";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(BomOverviewSpecialLine, "ddmrp", {
|
||||
props: {
|
||||
...BomOverviewSpecialLine.props,
|
||||
showOptions: {
|
||||
...BomOverviewSpecialLine.showOptions,
|
||||
is_buffered: Boolean,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t
|
||||
t-name="ddmrp.BomOverviewSpecialLine"
|
||||
t-inherit="mrp.BomOverviewSpecialLine"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//td[@name='td_mrp_bom']" position="before">
|
||||
<td t-if="showBuffered" />
|
||||
</xpath>
|
||||
<xpath expr="//td[@t-if='showLeadTimes']" position="after">
|
||||
<td t-if="showLeadTimes" />
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {BomOverviewTable} from "@mrp/components/bom_overview_table/mrp_bom_overview_table";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(BomOverviewTable.prototype, "ddmrp", {
|
||||
// ---- Getters ----
|
||||
|
||||
get showBuffered() {
|
||||
return this.props.showOptions.is_buffered;
|
||||
},
|
||||
});
|
||||
|
||||
patch(BomOverviewTable, "ddmrp", {
|
||||
props: {
|
||||
...BomOverviewTable.props,
|
||||
showOptions: {
|
||||
...BomOverviewTable.showOptions,
|
||||
is_buffered: Boolean,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t
|
||||
t-name="ddmrp.BomOverviewTable"
|
||||
t-inherit="mrp.BomOverviewTable"
|
||||
t-inherit-mode="extension"
|
||||
owl="1"
|
||||
>
|
||||
<xpath expr="//th[@name='th_mrp_bom_h']" position="before">
|
||||
<th t-if="showBuffered" class="text-center">Buffered</th>
|
||||
</xpath>
|
||||
<xpath expr="//thead/tr/th[@t-if='showLeadTimes']" position="after">
|
||||
<th
|
||||
t-if="showLeadTimes"
|
||||
class="text-end"
|
||||
title="Decoupled Lead Time of the BoM."
|
||||
>DLT</th>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//td[@name='td_mrp_bom_f']" position="before">
|
||||
<td t-if="showBuffered" />
|
||||
</xpath>
|
||||
<xpath expr="//tfoot/tr/td[@t-if='showLeadTimes']" position="after">
|
||||
<td t-if="showLeadTimes" />
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//td[@name='td_mrp_bom_b']" position="before">
|
||||
<td t-if="showBuffered" />
|
||||
</xpath>
|
||||
<xpath expr="//tfoot/t/tr/td[@t-if='showLeadTimes']" position="after">
|
||||
<td t-if="showLeadTimes" />
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
.circle {
|
||||
padding: 0.3em 0.7em;
|
||||
border-radius: 25em;
|
||||
display: inline-cell;
|
||||
}
|
||||
.circle_dark_red {
|
||||
background-color: #8b0000;
|
||||
color: white;
|
||||
}
|
||||
.circle_red {
|
||||
background-color: #ff0000;
|
||||
color: white;
|
||||
}
|
||||
.circle_yellow {
|
||||
background-color: #ffff00;
|
||||
color: black;
|
||||
}
|
||||
.circle_green {
|
||||
background-color: #33cc33;
|
||||
color: white;
|
||||
}
|
||||
.popover {
|
||||
display: inline-table;
|
||||
}
|
||||
body.with-scrollbar {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import {FloatField} from "@web/views/fields/float/float_field";
|
||||
import {loadBundle} from "@web/core/assets";
|
||||
import {registry} from "@web/core/registry";
|
||||
import {useService} from "@web/core/utils/hooks";
|
||||
import {useUniquePopover} from "@web/core/model_field_selector/unique_popover_hook";
|
||||
|
||||
const {Component, markup, onWillStart} = owl;
|
||||
|
||||
export class StockBufferPopover extends Component {
|
||||
setup() {
|
||||
this.actionService = useService("action");
|
||||
this.orm = useService("orm");
|
||||
onWillStart(async () => {
|
||||
await loadBundle({
|
||||
jsLibs: [
|
||||
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-3.1.1.min.js",
|
||||
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-api-3.1.1.min.js",
|
||||
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-widgets-3.1.1.min.js",
|
||||
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-tables-3.1.1.min.js",
|
||||
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-mathjax-3.1.1.min.js",
|
||||
"/web_widget_bokeh_chart/static/src/lib/bokeh/bokeh-gl-3.1.1.min.js",
|
||||
],
|
||||
});
|
||||
var bufferId = this.props.record.resId;
|
||||
var bufferField = this.props.buffer_id;
|
||||
if (bufferField && this.props.record.data[bufferField]) {
|
||||
if (
|
||||
("field" in this.props.record.data[bufferField] &&
|
||||
this.props.record.data[bufferField].field.type ==
|
||||
"many2many") ||
|
||||
bufferField.endsWith("_ids")
|
||||
) {
|
||||
if (this.props.record.data[bufferField].records.length > 0) {
|
||||
bufferId = this.props.record.data[bufferField].records[0].resId;
|
||||
} else {
|
||||
bufferId = 0; // Relation is blank, no buffer.
|
||||
}
|
||||
} else {
|
||||
// Assume m2o
|
||||
bufferId = this.props.record.data[bufferField][0];
|
||||
}
|
||||
} else if (bufferField) {
|
||||
bufferId = 0; // Relation is blank, no buffer.
|
||||
}
|
||||
if (bufferId == 0) {
|
||||
return;
|
||||
}
|
||||
this.bokeh_chart = await this.orm.read(
|
||||
"stock.buffer",
|
||||
[bufferId],
|
||||
[this.props.field]
|
||||
);
|
||||
});
|
||||
}
|
||||
get json_value() {
|
||||
try {
|
||||
var value = JSON.parse(this.bokeh_chart[0][this.props.field]);
|
||||
value.div = markup(value.div.trim());
|
||||
return value;
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
StockBufferPopover.template = "ddmrp.StockBufferPopover";
|
||||
|
||||
export class StockBufferInfoWidget extends FloatField {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.popover = useUniquePopover();
|
||||
}
|
||||
|
||||
get classFromDecoration() {
|
||||
var decorationName = this.props.record.data[this.props.color_from];
|
||||
if (decorationName !== "" && decorationName.length > 1) {
|
||||
decorationName = "circle" + decorationName.slice(1);
|
||||
return `${decorationName}`;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
showPopup(ev) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
this.popover.add(
|
||||
ev.currentTarget,
|
||||
this.constructor.components.Popover,
|
||||
{
|
||||
bus: this.bus,
|
||||
record: this.props.record,
|
||||
field: this.props.field,
|
||||
color_from: this.props.color_from,
|
||||
buffer_id: this.props.buffer_id,
|
||||
},
|
||||
{
|
||||
position: "right",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
StockBufferInfoWidget.components = {
|
||||
...StockBufferInfoWidget.components,
|
||||
Popover: StockBufferPopover,
|
||||
};
|
||||
StockBufferInfoWidget.template = "ddmrp.StockBufferInfoWidget";
|
||||
|
||||
StockBufferInfoWidget.props = {
|
||||
...StockBufferInfoWidget.props,
|
||||
color_from: {type: String, optional: true},
|
||||
field: {type: String, optional: true},
|
||||
buffer_id: {type: String, optional: true},
|
||||
};
|
||||
|
||||
const StockBufferInfoWidgetExtractProps = StockBufferInfoWidget.extractProps;
|
||||
StockBufferInfoWidget.extractProps = ({attrs, field}) => {
|
||||
return Object.assign(StockBufferInfoWidgetExtractProps({attrs, field}), {
|
||||
color_from: attrs.options.color_from,
|
||||
field: attrs.options.field,
|
||||
buffer_id: attrs.options.buffer_id,
|
||||
});
|
||||
};
|
||||
|
||||
registry.category("fields").add("stock_buffer_info", StockBufferInfoWidget);
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<template id="template" xml:space="preserve">
|
||||
|
||||
<!-- TODO: rename this to QtyAtDate in master version -->
|
||||
<t
|
||||
t-name="ddmrp.StockBufferInfoWidget"
|
||||
t-inherit="web.FloatField"
|
||||
owl="1"
|
||||
t-inherit-mode="primary"
|
||||
>
|
||||
<xpath expr="//span" position="attributes">
|
||||
<attribute name="t-on-click">showPopup</attribute>
|
||||
<attribute name="class">circle</attribute>
|
||||
<attribute name="t-att-class">classFromDecoration</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
<t t-name="ddmrp.StockBufferPopover" owl="1">
|
||||
<div>
|
||||
<t t-out="json_value.div" />
|
||||
<script type="text/javascript" t-out="json_value.script" />
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue