Example #1
0
 def _get_attr_pw(self, design, attr):
     price = 0
     weight = 0
     if attr.attribute_type == "select":
         price = resolve_attr(design, '%s.price' % (attr.name))
         weight = resolve_attr(design, '%s.weight' % (attr.name))
     elif attr.attribute_type == "multiselect":
         options = resolve_attr(design, attr.name)
         for opt in options:
             price = price + resolve_attr(opt, 'price')
             weight = weight + resolve_attr(opt, 'weight')
     if price is None:
         price = 0
     if weight is None:
         weight = 0
     return price, weight
Example #2
0
 def _get_attr_pw(self, design, attr):
     price = 0
     weight = 0
     if attr.attribute_type == "select":
         price = resolve_attr(design,'%s.price'%(attr.name))
         weight = resolve_attr(design,'%s.weight'%(attr.name))
     elif attr.attribute_type == "multiselect":
         options = resolve_attr(design,attr.name)
         for opt in options:
             price = price + resolve_attr(opt,'price')
             weight = weight + resolve_attr(opt,'weight')
     if price is None:
         price = 0
     if weight is None:
         weight = 0            
     return price, weight
Example #3
0
def email_notify(cr,
                 uid,
                 obj_name,
                 obj_ids,
                 actions,
                 action,
                 subject_fields=None,
                 email_to=None,
                 context=None):
    '''
    @param param:obj_name the model name that related to email, 'hr.holiday'
    @param param:object ids list, [1,2,3...]
    @param param:actions, one dict that define the action name and related message and groups
    actions = {'confirmed':{'msg':'need your approval','groups':['metro_purchase.group_pur_req_checker']},
                  'approved':{'msg':'approved, please issue PO','groups':['metro_purchase.group_pur_req_buyer']},
                  'rejected':{'msg':'was rejected, please check','groups':[]},
                  'in_purchase':{'msg':'is in purchasing','groups':[],},
                  'done':{'msg':'was done','groups':[]},
                  'cancel':{'msg':'was cancelled','groups':[]},
                  }  
    @param param: optional, subject_fields, one list that will generated the subject, if missing then user object.name
    @param email_to:optional, email to addresss
    '''
    pool = pooler.get_pool(cr.dbname)
    model_obj = pool.get('ir.model.data')
    obj_obj = pool.get(obj_name)
    if actions.get(action, False):
        msg = actions[action].get('msg')
        group_params = actions[action].get('groups')
        for order in obj_obj.browse(cr, uid, obj_ids, context=context):
            #email to groups
            email_group_ids = []
            for group_param in group_params:
                grp_data = group_param.split('.')
                email_group_ids.append(
                    model_obj.get_object_reference(cr, uid, grp_data[0],
                                                   grp_data[1])[1])
            #email messages
            subject_sub = ""
            if not subject_fields:
                subject_sub = order._description
            else:
                for field in subject_fields:
                    subject_sub += '%s,' % (resolve_attr(order, field), )
            email_subject = '%s: %s %s' % (obj_obj._description, subject_sub,
                                           msg)
            email_body = email_subject
            #the current user is the from user
            email_from = pool.get("res.users").read(cr,
                                                    uid,
                                                    uid, ['email'],
                                                    context=context)['email']
            #send emails
            email_send_group(cr, uid, email_from, email_to, email_subject,
                             email_body, email_group_ids, context)
Example #4
0
def email_notify(cr, uid, obj_name, obj_ids, actions, action, subject_fields = None, email_to = None, context=None):
    '''
    @param param:obj_name the model name that related to email, 'hr.holiday'
    @param param:object ids list, [1,2,3...]
    @param param:actions, one dict that define the action name and related message and groups
    actions = {'confirmed':{'msg':'need your approval','groups':['metro_purchase.group_pur_req_checker']},
                  'approved':{'msg':'approved, please issue PO','groups':['metro_purchase.group_pur_req_buyer']},
                  'rejected':{'msg':'was rejected, please check','groups':[]},
                  'in_purchase':{'msg':'is in purchasing','groups':[],},
                  'done':{'msg':'was done','groups':[]},
                  'cancel':{'msg':'was cancelled','groups':[]},
                  }  
    @param param: optional, subject_fields, one list that will generated the subject, if missing then user object.name
    @param email_to:optional, email to addresss
    '''
    pool =  pooler.get_pool(cr.dbname)
    model_obj = pool.get('ir.model.data')
    obj_obj = pool.get(obj_name)
    if actions.get(action,False):
        msg = actions[action].get('msg')
        group_params = actions[action].get('groups')
        for order in obj_obj.browse(cr, uid, obj_ids, context=context):
            #email to groups
            email_group_ids = []
            for group_param in group_params:
                grp_data = group_param.split('.')
                email_group_ids.append(model_obj.get_object_reference(cr, uid, grp_data[0], grp_data[1])[1])
            #email messages      
            subject_sub = ""       
            if not subject_fields:
                subject_sub = order._description
            else:
                for field in subject_fields:
                    subject_sub +=  '%s,'%(resolve_attr(order, field),)
            email_subject = '%s: %s %s'%(obj_obj._description, subject_sub, msg)
            email_body = email_subject
            #the current user is the from user
            email_from = pool.get("res.users").read(cr, uid, uid, ['email'],context=context)['email']
            #send emails
            email_send_group(cr, uid, email_from, email_to, email_subject,email_body, email_group_ids, context)