Skip to content

Commit

Permalink
[IMP] Preserve manually modified price in most cases
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Dec 20, 2015
1 parent ae3aa56 commit a10bc11
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pos_pricelist/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,26 @@ function pos_pricelist_models(instance, module) {
* @param quantity
*/
set_quantity: function (quantity) {
OrderlineParent.prototype.set_quantity.apply(this, arguments);
var partner = this.order ? this.order.get_client() : null;
var product = this.product;
var db = this.pos.db;
var old_price = 0;
if (this.get_quantity()) {
old_price = this.pos.pricelist_engine.compute_price_all(
db, product, partner, this.get_quantity()
);
}
OrderlineParent.prototype.set_quantity.apply(this, arguments);
var price = this.pos.pricelist_engine.compute_price_all(
db, product, partner, quantity
);
if (price !== false) {
/* Update the price if the unit price is actually different from
the unit price of the previous quantity, to preserve manually
entered prices as much as possible. */
if (price !== false && price !== old_price) {
this.price = price;
this.trigger('change', this);
}
this.trigger('change', this);
},
/**
* override this method to take fiscal positions in consideration
Expand Down

0 comments on commit a10bc11

Please sign in to comment.