Browse Source

[IMP] add the possibility to force the minimum quantity to subscribe on

the share_type
pull/1/head
houssine 8 years ago
parent
commit
70b44f5676
  1. 2
      easy_my_coop/controllers/main.py
  2. 1
      easy_my_coop/models/product.py
  3. 3
      easy_my_coop/static/src/js/easy_my_coop.js

2
easy_my_coop/controllers/main.py

@ -99,7 +99,7 @@ class WebsiteSubscription(http.Controller):
@http.route(['/subscription/get_share_product'], type='json', auth="public", methods=['POST'], website=True) @http.route(['/subscription/get_share_product'], type='json', auth="public", methods=['POST'], website=True)
def get_share_product(self, share_product_id, **kw): def get_share_product(self, share_product_id, **kw):
product = request.env['product.template'].sudo().browse(int(share_product_id)) product = request.env['product.template'].sudo().browse(int(share_product_id))
return {product.id: {'list_price':product.list_price,'min_qty':product.minimum_quantity}}
return {product.id: {'list_price':product.list_price,'min_qty':product.minimum_quantity,'force_min_qty':product.force_min_qty}}
@http.route(['/subscription/subscribe_share'], type='http', auth="public", website=True) @http.route(['/subscription/subscribe_share'], type='http', auth="public", website=True)
def share_subscription(self, **kwargs): def share_subscription(self, **kwargs):

1
easy_my_coop/models/product.py

@ -9,6 +9,7 @@ class ProductTemplate(models.Model):
display_on_website = fields.Boolean(string='Display on website') display_on_website = fields.Boolean(string='Display on website')
default_share_product = fields.Boolean(string='Default share product') default_share_product = fields.Boolean(string='Default share product')
minimum_quantity = fields.Integer(string='Minimum quantity', default=1) minimum_quantity = fields.Integer(string='Minimum quantity', default=1)
force_min_qty = fields.Boolean(String="Force minimum quantity?")
by_company = fields.Boolean(string="Can be subscribed by companies?") by_company = fields.Boolean(string="Can be subscribed by companies?")
by_individual = fields.Boolean(string="Can be subscribed by individuals?") by_individual = fields.Boolean(string="Can be subscribed by individuals?")

3
easy_my_coop/static/src/js/easy_my_coop.js

@ -14,6 +14,9 @@ $(document).ready(function () {
.then(function (data) { .then(function (data) {
$('#share_price').text(data[share_product_id].list_price); $('#share_price').text(data[share_product_id].list_price);
$('input.js_quantity').val(data[share_product_id].min_qty); $('input.js_quantity').val(data[share_product_id].min_qty);
if(data[share_product_id].force_min_qty == true){
$('input.js_quantity').data("min",data[share_product_id].min_qty);
}
$('input.js_quantity').change(); $('input.js_quantity').change();
var $share_price = $('#share_price').text() var $share_price = $('#share_price').text()
$('input[name="total_parts"]').val($('input.js_quantity').val()*$share_price); $('input[name="total_parts"]').val($('input.js_quantity').val()*$share_price);

Loading…
Cancel
Save