Ejemplo n.º 1
0
 def approve(self, ids, context={}):
     if not check_permission_other("production_safe_in"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {"next": {"name": "barcode_safe_in", "active_id": obj.id}, "flash": "DC to safe approved successfully"}
Ejemplo n.º 2
0
 def approve(self, ids, context={}):
     if not check_permission_other("sale_approve_done"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {
         "next": {"name": "sale", "mode": "form", "active_id": obj.id},
         "flash": "Sales order approved successfully",
     }
Ejemplo n.º 3
0
 def approve(self, ids, context={}):
     if not check_permission_other("production_safe_in"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {
         "next": {
             "name": "barcode_safe_in",
             "active_id": obj.id,
         },
         "flash": "DC to safe approved successfully",
     }
Ejemplo n.º 4
0
 def approve(self, ids, context={}):
     if not check_permission_other("production_approve_split"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {
         "next": {
             "name": "split_production",
             "active_id": obj.id,
         },
         "flash": "Split order approved successfully",
     }
Ejemplo n.º 5
0
 def approve(self, ids, context={}):
     if not check_permission_other("stock_transfer"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {
         "next": {
             "name": "barcode_transfer",
             "active_id": obj.id,
         },
         "flash": "Stock transfer approved successfully",
     }
Ejemplo n.º 6
0
 def qc_approve_done(self, ids, context={}):
     if not check_permission_other("production_approve_qc"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"done_qc_approved_by_id": user_id})
     return {
         "next": {
             "name": "production",
             "mode": "form",
             "active_id": obj.id,
         },
         "flash": "Production order QC completion approved successfully",
     }
Ejemplo n.º 7
0
 def approve_done(self, ids, context={}):
     if not check_permission_other("job_approve_done"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"done_approved_by_id": user_id})
     return {
         "next": {
             "name": "job",
             "mode": "form",
             "active_id": obj.id,
         },
         "flash": "Service order completion approved successfully",
     }
Ejemplo n.º 8
0
def _if_perm(this, options, perm):
    if access.check_permission_other(perm):
        return options['fn'](this)
    else:
        return options['inverse'](this)
Ejemplo n.º 9
0
 def get(self):
     db = get_connection()
     try:
         ctx = self.context
         website_id=self.request.headers.get("X-Website-ID")
         if website_id:
             website_id=int(website_id)
         else:
             res=get_model("website").search([["state","=","active"]])
             if not res:
                 raise Exception("No website found")
             website_id=res[0]
         self.website_id=website_id
         website=get_model("website").browse(website_id)
         browse_ctx={
             "website_id": website.id,
             "theme_id": website.theme_id.id,
             "sale_channel_id": website.sale_channel_id.id,
             "pricelist_id": website.sale_channel_id.pricelist_id.id if website.sale_channel_id else None,
         }
         user_id=self.get_cookie("user_id",None)
         if user_id:
             user_id=int(user_id)
             user=get_model("base.user").browse(user_id)
             contact = user.contact_id
             pricelist_ids=[website.sale_channel_id.pricelist_id.id]
             if contact.groups:
                 for group in contact.groups:
                     if group.sale_price_list_id:
                         pricelist_ids.append(group.sale_price_list_id.id)
             browse_ctx["pricelist_ids"]=pricelist_ids
         product_id = self.get_argument("product_id")
         product_id = int(product_id)
         prod = get_model("product").browse([product_id],context=browse_ctx)[0]
         if not prod.is_published and not access.check_permission_other("ecom_preview_product"):
             raise Exception("Product is not published")
         ctx["product"] = prod
         prod_vals = {
             "name": prod.name,
             "code": prod.code,
             "decription": prod.description,
             "image": prod.image,
             "sale_price": prod.customer_price,
             "variants": [],
             "images": [],
             "custom_options": [],
             "attributes": [],
             "type": prod.type,
         }
         if prod.customer_has_discount:
             prod_vals["old_price"] = prod.sale_price
         for img in prod.images:
             img_vals = {
                 "image": img.image,
                 "title": img.title,
             }
             prod_vals["images"].append(img_vals)
         for var in prod.variants:
             var_vals = {
                 "id": var.id,
                 "name": var.name,
                 "price": var.customer_price,
                 "stock_qty": var.stock_qty,
                 "image": var.image,
                 "images": [prod_image.image for prod_image in var.images],
                 "attributes": [],
             }
             if var.customer_has_discount:
                 var_vals["old_price"] = var.sale_price
             for attr in var.attributes:
                 attr_vals = {
                     "name": attr.attribute_id.name if attr.attribute_id else None,
                     "code": attr.attribute_id.code if attr.attribute_id else None,
                     "value": attr.option_id.code if attr.option_id else None,
                 }
                 var_vals["attributes"].append(attr_vals)
             prod_vals["variants"].append(var_vals)
         for attr in prod.attributes:
             attr_vals = {
                 "name": attr.attribute_id.name if attr.attribute_id else None,
                 "code": attr.attribute_id.code if attr.attribute_id else None,
                 "value": attr.option_id.code if attr.option_id else None,
             }
             prod_vals["attributes"].append(attr_vals)
         ctx["parent_categ_list"] = list_categ_parent(prod.categ_id, categ_list=[])
         ctx["product_json"] = utils.json_dumps(prod_vals)
         content = render("ecom_product", ctx)
         ctx["content"] = content
         html = render("cms_layout", ctx)
         self.write(html)
         db.commit()
     except:
         self.redirect("/cms_page_not_found")
         import traceback
         traceback.print_exc()
         db.rollback()
Ejemplo n.º 10
0
 def get(self):
     db = get_connection()
     try:
         ctx = self.context
         website_id = self.request.headers.get("X-Website-ID")
         if website_id:
             website_id = int(website_id)
         else:
             res = get_model("website").search([["state", "=", "active"]])
             if not res:
                 raise Exception("No website found")
             website_id = res[0]
         self.website_id = website_id
         website = get_model("website").browse(website_id)
         browse_ctx = {
             "website_id":
             website.id,
             "theme_id":
             website.theme_id.id,
             "sale_channel_id":
             website.sale_channel_id.id,
             "pricelist_id":
             website.sale_channel_id.pricelist_id.id
             if website.sale_channel_id else None,
         }
         user_id = self.get_cookie("user_id", None)
         if user_id:
             user_id = int(user_id)
             user = get_model("base.user").browse(user_id)
             contact = user.contact_id
             pricelist_ids = [website.sale_channel_id.pricelist_id.id]
             if contact.groups:
                 for group in contact.groups:
                     if group.sale_price_list_id:
                         pricelist_ids.append(group.sale_price_list_id.id)
             browse_ctx["pricelist_ids"] = pricelist_ids
         product_id = self.get_argument("product_id")
         product_id = int(product_id)
         prod = get_model("product").browse([product_id],
                                            context=browse_ctx)[0]
         if not prod.is_published and not access.check_permission_other(
                 "ecom_preview_product"):
             raise Exception("Product is not published")
         ctx["product"] = prod
         prod_vals = {
             "name": prod.name,
             "code": prod.code,
             "decription": prod.description,
             "image": prod.image,
             "sale_price": prod.customer_price,
             "variants": [],
             "images": [],
             "custom_options": [],
             "attributes": [],
             "type": prod.type,
         }
         if prod.customer_has_discount:
             prod_vals["old_price"] = prod.sale_price
         for img in prod.images:
             img_vals = {
                 "image": img.image,
                 "title": img.title,
             }
             prod_vals["images"].append(img_vals)
         for var in prod.variants:
             var_vals = {
                 "id": var.id,
                 "name": var.name,
                 "price": var.customer_price,
                 "stock_qty": var.stock_qty,
                 "image": var.image,
                 "images": [prod_image.image for prod_image in var.images],
                 "attributes": [],
             }
             if var.customer_has_discount:
                 var_vals["old_price"] = var.sale_price
             for attr in var.attributes:
                 attr_vals = {
                     "name":
                     attr.attribute_id.name if attr.attribute_id else None,
                     "code":
                     attr.attribute_id.code if attr.attribute_id else None,
                     "value":
                     attr.option_id.code if attr.option_id else None,
                 }
                 var_vals["attributes"].append(attr_vals)
             prod_vals["variants"].append(var_vals)
         for attr in prod.attributes:
             attr_vals = {
                 "name":
                 attr.attribute_id.name if attr.attribute_id else None,
                 "code":
                 attr.attribute_id.code if attr.attribute_id else None,
                 "value": attr.option_id.code if attr.option_id else None,
             }
             prod_vals["attributes"].append(attr_vals)
         ctx["parent_categ_list"] = list_categ_parent(prod.categ_id,
                                                      categ_list=[])
         ctx["product_json"] = utils.json_dumps(prod_vals)
         content = render("ecom_product", ctx)
         ctx["content"] = content
         html = render("cms_layout", ctx)
         self.write(html)
         db.commit()
     except:
         self.redirect("/cms_page_not_found")
         import traceback
         traceback.print_exc()
         db.rollback()
Ejemplo n.º 11
0
 def approve_split(self, ids, context={}):
     if not check_permission_other("production_approve_split"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"split_approved_by_id": user_id})
Ejemplo n.º 12
0
def _if_perm(this, options, perm):
    if access.check_permission_other(perm):
        return options['fn'](this)
    else:
        return options['inverse'](this)