Skip to content

Commit

Permalink
Added stock_movement.js to git. #1659
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdspencer77 committed Feb 19, 2025
1 parent 7f884c5 commit bec847e
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions src/static/js/stock_movement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*global $, jQuery, _, asm, common, config, controller, dlgfx, edit_header, format, header, html, tableform, validate */

$(function() {

"use strict";

const stock_movement = {

model: function() {
const dialog = {
add_title: _("Add product movement"),
edit_title: _("Edit product movement"),
edit_perm: 'vsl',
close_on_ok: false,
hide_read_only: true,
columns: 1,
width: 500,
fields: [
{ json_field: "PRODUCTNAME", post_field: "productname", label: _("Name"), type: "text", validation: "notblank" },
{ json_field: "PRODUCTTYPE", post_field: "producttype", label: _("Product type"), type: "select", options: controller.producttypes, validation: "notnull" },
{ json_field: "BARCODE", post_field: "barcode", label: _("Barcode"), type: "text" },
{ json_field: "PLU", post_field: "plu", label: _("PLU"), type: "text" },
{ json_field: "DESCRIPTION", post_field: "productdescription", label: _("Description"), type: "textarea" },
{ json_field: "TAXRATE", post_field: "taxrate", label: _("Tax Rate"), type: "select", options: controller.taxrates, validation: "notnull" },
{ json_field: "RETIRED", post_field: "retired", label: _("Retired"), type: "check" },
{ json_field: "SUPPLIERID", post_field: "supplierid", label: _("Supplier"), type: "person", personfilter: "supplier", validation:"notzero" },
{ json_field: "SUPPLIERCODE", post_field: "suppliercode", label: _("Supplier code"), type: "text", colclasses: "bottomborder" },
{ json_field: "PURCHASEUNITTYPE", post_field: "purchaseunittype", label: _("Purchase Unit"), type: "select",
options: ["0|" + _("Unit").toLowerCase(), "1|kg", "2|g", "3|l", "4|ml", "5|" + _("Custom").toLowerCase()]
},
{ json_field: "CUSTOMPURCHASEUNIT", post_field: "custompurchaseunit", label: _("Custom Unit"), type: "text" },
{ json_field: "COSTPRICE", post_field: "costprice", label: _("Cost price"), type: "currency", colclasses: "bottomborder" },
{ json_field: "UNITTYPE", post_field: "unittype", label: _("Unit"), type: "select", options: ["0|" + _("Purchase unit").toLowerCase(), "1|kg", "2|g", "3|l", "4|ml", "5|" + _("Custom").toLowerCase()] },
{ json_field: "CUSTOMUNIT", post_field: "customunit", label: _("Custom Unit"), type: "text" },
{ json_field: "RETAILPRICE", post_field: "retailprice", label: _("Unit price"), type: "currency" },
{ json_field: "UNITRATIO", post_field: "unitratio", label: _("Unit Ratio"), type: "number", validation: "notblank", defaultval: 1 }
]
};

const table = {
rows: controller.rows,
idcolumn: "ID",
columns: [
{ field: "USAGEDATE", display: _("Date"), formatter: function(row) {
return tableform.table_render_edit_link(row.ID, format.date(row.USAGEDATE));
} },
{ field: "PRODUCTNAME", display: _("Product") },
{ field: "MODQUANTITY", display: _("Quantity") },
{ field: "UNIT", display: _("Unit") },
{ field: "FROMNAME", display: _("From") },
{ field: "TONAME", display: _("To") },
{ field: "COMMENTS", display: _("Comments") }
]
};

const buttons = [
{ id: "delete", text: _("Delete"), icon: "delete", enabled: "multi", perm: "dsl",
click: async function() {
await tableform.delete_dialog();
tableform.buttons_default_state(buttons);
let ids = tableform.table_ids(table);
await common.ajax_post("stock_movement", "mode=delete&ids=" + ids);
tableform.table_remove_selected_from_json(table, controller.rows);
tableform.table_update(table);
}
}
];
this.dialog = dialog;
this.buttons = buttons;
this.table = table;
},

render: function() {
let s = "";
this.model();
s += tableform.dialog_render(this.dialog);
s += html.content_header(_("Stock movement"));
s += tableform.buttons_render(this.buttons);
s += tableform.table_render(this.table);
s += html.content_footer();
return s;
},

bind: function() {
tableform.dialog_bind(this.dialog);
tableform.buttons_bind(this.buttons);
tableform.table_bind(this.table, this.buttons);

},

destroy: function() {
tableform.dialog_destroy();
},

/*set_extra_fields: function(row) {
row.STOCKLOCATIONNAME = common.get_field(controller.stocklocations, row.STOCKLOCATIONID, "LOCATIONNAME");
},*/

name: "stock_movement",
animation: "book",
title: function() { return _("Stock movement"); },
routes: {
"stock_movement": function() { common.module_loadandstart("stock_movement", "stock_movement?" + this.rawqs); }
}

};

common.module_register(stock_movement);

});

0 comments on commit bec847e

Please sign in to comment.