diff --git a/ayanova/src/components/work-order-item-parts.vue b/ayanova/src/components/work-order-item-parts.vue
index 54de2991..aad66690 100644
--- a/ayanova/src/components/work-order-item-parts.vue
+++ b/ayanova/src/components/work-order-item-parts.vue
@@ -21,6 +21,17 @@
{{ $ay.t("New") }}
+
+
+ $ayiFan
+
+ {{
+ $ay.t("WorkOrderGenerateUnit")
+ }}
+
$ayiObjectGroup
@@ -504,6 +515,23 @@ export default {
}
},
methods: {
+ generateUnit() {
+ const thisPart = this.value.items[this.activeWoItemIndex].parts[
+ this.activeItemIndex
+ ];
+ this.$router.push({
+ name: "svc-units",
+ params: {
+ recordid: 0,
+ genFromPart: {
+ customerId: this.value.customerId,
+ partId: thisPart.partId,
+ purchaseDate: this.value.serviceDate,
+ serial: thisPart.serials
+ }
+ }
+ });
+ },
async selectSerials() {
this.availableSerials.splice(0);
this.selectedSerials.splice(0);
diff --git a/ayanova/src/views/svc-unit.vue b/ayanova/src/views/svc-unit.vue
index 2307af80..39ea8d67 100644
--- a/ayanova/src/views/svc-unit.vue
+++ b/ayanova/src/views/svc-unit.vue
@@ -759,6 +759,43 @@ export default {
"Copy"
)}`;
setDirty = true;
+ } else {
+ //check for generate unit from part info on route params
+ //(set by workorder item part when user selects generate unit from part)
+ let gen = this.$route.params.genFromPart;
+ if (gen) {
+ /* genFromPart: {
+ customerId: this.value.customerId,
+ partId: thisPart.partId,
+ purchaseDate: this.value.serviceDate,
+ serial: thisPart.serials
+ }
+
+ /*
+ owner is workorder customer
+ Description is part name
+ purchased here is true
+ purchased date is service date of workorder
+ Serial number is part serial number if set
+
+ */
+ //get the part then set the values accordingly
+ let res = await window.$gz.api.get(`part/${gen.partId}`);
+ if (res.error) {
+ window.$gz.eventBus.$emit(
+ "notify-warning",
+ window.$gz.errorHandler.errorToString(res, this)
+ );
+ } else {
+ let p = res.data;
+ this.obj.boughtHere = true;
+ this.obj.customerId = gen.customerId;
+ this.obj.serial = gen.serial;
+ this.obj.purchasedDate = gen.purchaseDate;
+ this.obj.description = p.partNumber + " " + p.name;
+ }
+ setDirty = true;
+ }
}
}