Browse Source

[UPDT] Sep 27 : Product Combo Pack

pull/219/head
AjmalCybro 3 years ago
parent
commit
175b93ec10
  1. 2
      product_combo_pack/__manifest__.py
  2. 26
      product_combo_pack/models/product_form.py
  3. 3
      product_combo_pack/security/ir.model.access.csv

2
product_combo_pack/__manifest__.py

@ -23,7 +23,7 @@
{
'name': 'Product Pack',
'version': '15.0.1.0.0',
'version': '15.0.1.1.1',
'summary': 'Manage Products as Pack',
'description': 'Manage Products as Pack',
'category': 'Sales',

26
product_combo_pack/models/product_form.py

@ -30,7 +30,8 @@ class ProductPack(models.Model):
def default_pack_location(self):
company_user = self.env.company
warehouse = self.env['stock.warehouse'].search([('company_id', '=', company_user.id)], limit = 1)
warehouse = self.env['stock.warehouse'].search([(
'company_id', '=', company_user.id)], limit=1)
if warehouse:
return warehouse.lot_stock_id.id
@ -62,15 +63,16 @@ class ProductPack(models.Model):
def write(self, values):
super(ProductPack, self).write(values)
if self.is_pack:
if not self.pack_products_ids:
raise UserError(_(
'You need to add atleast one product in the Pack...!'))
if self.type == 'service':
raise UserError(_('You cannot define a pack product as a service..!'))
for rec in self:
if rec.is_pack:
if not rec.pack_products_ids:
raise UserError(_(
'You need to add atleast one product in the Pack...!'))
if rec.type == 'service':
raise UserError(_('You cannot define a pack product as a service..!'))
def update_price_product(self):
self.lst_price = self.pack_price
self.list_price = self.pack_price
def get_quantity(self):
total_quantity = 1
@ -93,7 +95,8 @@ class ProductPack(models.Model):
product_id = len(self.product_variant_ids) == 1 and self.product_variant_id.id
location_id = self.pack_location_id.id
if not location_id:
warehouse = self.env['stock.warehouse'].search([('company_id', '=', company_user.id)], limit = 1)
warehouse = self.env['stock.warehouse'].search([(
'company_id', '=', company_user.id)], limit = 1)
location_id = warehouse.lot_stock_id.id
if not location_id:
raise UserError(_(
@ -108,9 +111,10 @@ class ProductPack(models.Model):
def change_quantity_based_on_location(self):
for line in self.pack_products_ids:
stock_quant = self.env['stock.quant'].search(
[('product_id', '=', line.product_id.id), ('location_id', '=', self.pack_location_id.id)])
[('product_id', '=', line.product_id.id), (
'location_id', '=', self.pack_location_id.id)])
if stock_quant:
line.total_available_quantity = stock_quant.quantity
else:
line.total_available_quantity = stock_quant.quantity
line.total_available_quantity = stock_quant.quantity

3
product_combo_pack/security/ir.model.access.csv

@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_pack_products,access.pack.products,model_pack_products,base.group_user,1,1,1,1
access_pack_products,access.pack.products,model_pack_products,base.group_user,1,1,1,1
select_product_pack,access.select.product.pack,model_select_product_pack,base.group_user,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_pack_products access.pack.products model_pack_products base.group_user 1 1 1 1
3 select_product_pack access.select.product.pack model_select_product_pack base.group_user 1 1 1 1
Loading…
Cancel
Save