improved_mo_origin: add source SO to shop floor view

This commit is contained in:
Marc Durepos 2024-07-03 11:01:30 -04:00
parent acf26d7c36
commit ec2c328f2c
5 changed files with 27 additions and 8 deletions

View file

@ -6,8 +6,8 @@ import {patch} from "@web/core/utils/patch";
patch(MrpDisplayAction.prototype, {
get fieldsStructure() {
const vals = super.fieldsStructure;
vals["mrp.production"].push("customer_ids", "upstream_production_ids");
vals["mrp.workorder"].push("customer_ids", "upstream_production_ids");
vals["mrp.production"].push("customer_ids");
vals["mrp.workorder"].push("customer_ids");
vals["res.partner"] = ["id", "display_name"];
return vals;
},

View file

@ -17,7 +17,7 @@ class MrpProduction(models.Model):
store=True,
compute_sudo=True,
)
source_sale_ids = fields.One2many(
source_sale_ids = fields.Many2many(
comodel_name="sale.order",
compute="_compute_source_sale_ids",
compute_sudo=True,

View file

@ -13,6 +13,13 @@ patch(MrpDisplay.prototype, {
fields: customerFields,
activeFields: customerFields,
};
const saleOrderFields = this.props.models.find(
(m) => m.resModel === "sale.order"
).fields;
params.config.activeFields.source_sale_ids.related = {
fields: saleOrderFields,
activeFields: saleOrderFields,
};
return params;
},
});

View file

@ -6,8 +6,9 @@ import {patch} from "@web/core/utils/patch";
patch(MrpDisplayAction.prototype, {
get fieldsStructure() {
const vals = super.fieldsStructure;
vals["mrp.production"].push("customer_ids", "source_sale_orders");
vals["res.partner"] = ["id", "display_name", "source_sale_orders"];
vals["mrp.production"].push("customer_ids", "source_sale_ids");
vals["res.partner"] = ["id", "display_name"];
vals["sale.order"] = ["id", "display_name"];
return vals;
},
});

View file

@ -2,9 +2,8 @@
<templates xml:space="preserver">
<t t-inherit="mrp_workorder.MrpDisplayRecord" t-inherit-mode="extension">
<xpath expr="//div[hasclass('card-header')]" position="inside">
<t
t-if="props.production.data.customer_ids &amp;&amp; props.production.data.customer_ids.records"
>
<t t-set="customers" t-value="props.production.data.customer_ids" />
<t t-if="customers &amp;&amp; customers.records">
<Many2ManyTagsField
name="'customer_ids'"
record="props.production"
@ -14,6 +13,18 @@
readonly="true"
/>
</t>
<t t-set="sale_orders" t-value="props.production.data.source_sale_ids" />
<t t-if="sale_orders &amp;&amp; sale_orders.records">
<Many2ManyTagsField
name="'source_sale_ids'"
record="props.production"
canCreate="false"
canCreateEdit="false"
canQuickCreate="false"
readonly="true"
/>
</t>
</xpath>
</t>
</templates>