rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
loc_id=False, product_id=False, context=None):
loc_id=False, product_id=False, uom_id=False, context=None):
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Insufficient Stock in Lot !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning}
'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0)
'message': _('You are moving %.2f %s products but only %.2f %s available in this lot.') % (product_qty, uom.name, prodlot.stock_available or 0.0, uom.name)
def onchange_lot_id(self, cr, uid, ids, prodlot_id=False, product_qty=False, loc_id=False, product_id=False, context=None): """ On change of production lot gives a warning message. @param prodlot_id: Changed production lot id @param product_qty: Quantity of product @param loc_id: Location id @param product_id: Product id @return: Warning message """ if not prodlot_id or not loc_id: return {} ctx = context and context.copy() or {} ctx['location_id'] = loc_id prodlot = self.pool.get('stock.production.lot').browse(cr, uid, prodlot_id, ctx) location = self.pool.get('stock.location').browse(cr, uid, loc_id) warning = {} if (location.usage == 'internal') and (product_qty > (prodlot.stock_available or 0.0)): warning = { 'title': _('Insufficient Stock in Lot !'), 'message': _('You are moving %.2f products but only %.2f available in this lot.') % (product_qty, prodlot.stock_available or 0.0) } return {'warning': warning}
def _file_get(self,cr, nodename=False, directory_id=False):
def _file_get(self,cr, nodename=False):
def _file_get(self,cr, nodename=False, directory_id=False): res = [] cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
def _file_get(self,cr, nodename=False, directory_id=False): res = [] cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',directory_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3)
return super(node_dir,self)._file_get(cr, nodename, self.dir_id)
res = super(node_dir,self)._file_get(cr, nodename) cntobj = self.context._dirobj.pool.get('document.directory.content') uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',self.dir_id) ] ids = cntobj.search(cr, uid, where, context=ctx) for content in cntobj.browse(cr, uid, ids, context=ctx): res3 = cntobj._file_get(cr, self, nodename, content) if res3: res.extend(res3) return res
def _file_get(self, cr, nodename=False): return super(node_dir,self)._file_get(cr, nodename, self.dir_id)
'password': generate_random_pass(),
'password': password,
def _create_new_share_users(self, cr, uid, wizard_data, group_id, context=None): user_obj = self.pool.get('res.users') current_user = user_obj.browse(cr, uid, uid) user_ids = [] if wizard_data.user_type == 'new': for new_user in wizard_data.new_users.split('\n'): # attempt to show more user-friendly msg than default constraint error existing = user_obj.search(cr, 1, [('login', '=', new_user)]) if existing: raise osv.except_osv(_('User already exists'), _('This username (%s) already exists, perhaps data has already been shared with this person.\nYou may want to try selecting existing shared users instead.')) user_id = user_obj.create(cr, 1, { 'login': new_user, 'password': generate_random_pass(), 'name': new_user, 'user_email': new_user, 'groups_id': [(6,0,[group_id])], 'share': True, 'company_id': current_user.company_id and current_user.company_id.id }) user_ids.append(user_id) return user_ids
uom_id = line.product_id.uom_po_id.id
uom_id = line.product_id.uom_po_id and line.product_id.uom_po_id.id or False
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
newdate = newdate - line.product_id.seller_ids[0].delay
newdate = newdate -(line.product_id.seller_ids and line.product_id.seller_ids[0].delay or DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
partner = line.product_id.seller_ids[0].name pricelist_id = partner.property_product_pricelist_purchase.id
partner = line.product_id.seller_ids and line.product_id.seller_ids[0].name or supplier_data pricelist_id = partner.property_product_pricelist_purchase and partner.property_product_pricelist_purchase.id
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID or list of IDs @param context: A standard dictionary @return: {} """ record_ids = context and context.get('active_ids', False) if record_ids: data = self.read(cr, uid, ids) company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id order_obj = self.pool.get('purchase.order') order_line_obj = self.pool.get('purchase.order.line') partner_obj = self.pool.get('res.partner') tender_line_obj = self.pool.get('purchase.requisition.line') pricelist_obj = self.pool.get('product.pricelist') prod_obj = self.pool.get('product.product') tender_obj = self.pool.get('purchase.requisition') acc_pos_obj = self.pool.get('account.fiscal.position') partner_id = data[0]['partner_id'] address_id = partner_obj.address_get(cr, uid, [partner_id], ['delivery'])['delivery'] list_line=[] purchase_order_line={} for tender in tender_obj.browse(cr, uid, record_ids): for line in tender.line_ids: uom_id = line.product_id.uom_po_id.id newdate = DateTime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead) newdate = newdate - line.product_id.seller_ids[0].delay
if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d')))
if idate: if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
def ics_datetime(idate, short=False): if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
return False
def ics_datetime(idate, short=False): if short: return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) else: return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S')
sub = res_obj.name att_infos = []
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
else: other_invitation_ids = [] for att2 in self.browse(cr, uid, other_invitation_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '<br>'.join(att_infos), 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: attach = self.get_ics_file(cr, uid, res_obj, context=context) tools.email_send( email_from, mail_to, sub, body, attach=attach and [('invitation.ics', attach)] or None, subtype='html', reply_to=email_from )
for att2 in self.browse(cr, uid, other_invitation_ids): att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) body_vals = {'name': res_obj.name, 'start_date': res_obj.date, 'end_date': res_obj.date_deadline or False, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '<br>'.join(att_infos), 'user': res_obj.user_id and res_obj.user_id.name or 'OpenERP User', 'sign': sign, 'company': company } body = html_invitation % body_vals if mail_to and email_from: attach = self.get_ics_file(cr, uid, res_obj, context=context) tools.email_send( email_from, mail_to, sub, body, attach=attach and [('invitation.ics', attach)] or None, subtype='html', reply_to=email_from )
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
'lines_ids': [(0,0,{
'line_ids': [(0,0,{
def make_po(self, cr, uid, ids, context={}): sequence_obj=self.pool.get('ir.sequence') res = super(mrp_procurement, self).make_po(cr, uid, ids, context) for proc_id,po_id in res.items(): procurement = self.browse(cr, uid, proc_id) if procurement.product_id.purchase_requisition: self.pool.get('purchase.requisition').create(cr, uid, { 'name': procurement.name, 'origin': procurement.name, 'date_end': procurement.date_planned, 'lines_ids': [(0,0,{ 'product_id': procurement.product_id.id, 'product_uom_id': procurement.product_uom.id, 'product_qty': procurement.product_qty
toremove = self.pool.get('account.analytic.line').search(cr, uid, [('move_id','=',line.id)], context=context)
toremove = analytic_line_obj.search(cr, uid, [('move_id','=',line.id)], context=context)
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
line.unlink(cr, uid, toremove, context=context)
analytic_line_obj.unlink(cr, uid, toremove, context=context)
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
ali_id=self.pool.get('account.analytic.line').create(cr,uid,al_vals)
ali_id=analytic_line_obj.create(cr, uid, al_vals, context=context)
def create_analytic_lines(self, cr, uid, ids, context={}): super(account_move_line, self).create_analytic_lines(cr, uid, ids, context) for line in self.browse(cr, uid, ids, context): if line.analytics_id: if not line.journal_id.analytic_journal_id: raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (line.journal_id.name,))
obj_model = self.pool.get('ir.model.data') obj_act = self.pool.get('ir.actions.act_window') order= obj_payment_order.browse(cr, uid, context['active_id'], context) t = order.mode and order.mode.type.code or 'manual' if t == 'manual' : obj_payment_order.set_done(cr,uid,context['active_id'],context) return {} gw = obj_payment_order.get_wizard(t) if not gw: obj_payment_order.set_done(cr,uid,context['active_id'],context) return {} module, wizard= gw result = obj_model._get_id(cr, uid, module, wizard) id = obj_model.read(cr, uid, [result], ['res_id'])[0]['res_id'] return obj_act.read(cr, uid, [id])[0]
return obj_payment_order.set_done(cr, uid, context['active_id'], context)
def launch_wizard(self, cr, uid, ids, context=None): """ Search for a wizard to launch according to the type. If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order') obj_model = self.pool.get('ir.model.data') obj_act = self.pool.get('ir.actions.act_window') order= obj_payment_order.browse(cr, uid, context['active_id'], context) t = order.mode and order.mode.type.code or 'manual' if t == 'manual' : obj_payment_order.set_done(cr,uid,context['active_id'],context) return {}
return self.pool.get('account.period').find(cr, uid)
period_ids = self.pool.get('account.period').find(cr, uid) return period_ids and period_ids[0] or False
def _get_period(self, cr, uid, context=None): """Return default period value""" return self.pool.get('account.period').find(cr, uid)
vals = model_obj.import_cal(cr, uid, data['file_path'], context['active_id'], context)
vals = model_obj.import_cal(cr, uid, base64.decodestring(data['file_path']), context['active_id'], context)
def process_imp_ics(self, cr, uid, ids, context=None): """ Process Import ics File. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of calendar event import’s IDs @return: dictionary of calendar evet import window with Import successful msg. """
cr.execute('SELECT SUM('+mode+') '\ 'FROM account_move_line '\ 'WHERE move_id=%s AND id<>%s', (move.id, line_id2))
cr.execute('SELECT SUM(%s) FROM account_move_line WHERE move_id=%%s AND id!=%%s' % (mode,), (move.id, line_id2))
def _centralise(self, cr, uid, move, mode, context=None): if context is None: context = {}
'process_type_id' :fields.many2one('change.process.type','Type Change'),
'process_type_id' :fields.many2one('document.change.process.type','Type Change'),
def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents return res
'user_id':field.many2one('res.users','Change Owner'),
'user_id':fields.many2one('res.users','Change Owner'),
def _latestmodification(self, cr, uid, ids, field_name, arg, context={}): res = {} #TODOto calculate latest modified date from all related documents return res
bom_point = sbom_obj.browse(cr, uid, [bom_id])[0]
bom_point = bom_obj.browse(cr, uid, [bom_id])[0]
def change_prod_qty(self, cr, uid, ids, context): """ Changes the Quantity of Product. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: """ record_id = context and context.get('active_id',False) assert record_id, _('Active Id is not found') prod_obj = self.pool.get('mrp.production') product_lines_obj = self.pool.get('mrp.production.product.line') bom_obj = self.pool.get('mrp.bom') for wiz_qty in self.browse(cr, uid, ids): prod = prod_obj.browse(cr, uid,record_id) prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty}) prod_obj.action_compute(cr, uid, [prod.id]) move_lines_obj = self.pool.get('stock.move') for move in prod.move_lines: bom_point = prod.bom_id bom_id = prod.bom_id.id if not bom_point: bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id) if not bom_id: raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product")) prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id}) bom_point = sbom_obj.browse(cr, uid, [bom_id])[0] if not bom_id: raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product")) factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, []) for r in res[0]: if r['product_id']== move.product_id.id: move_lines_obj.write(cr, uid,move.id, {'product_qty' : r['product_qty']}) for m in prod.move_created_ids: move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty}) return {}
'date': fields.datetime('Created Date'),
'date': fields.datetime('Creation Date'),
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
'location_dest_id': fields.many2one('stock.location', 'Dest. Location', required=True, select=True, help="Location where the system will stock the finished products."), 'address_id': fields.many2one('res.partner.address', 'Dest. Address', help="Address where goods are to be delivered"),
'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True, select=True, help="Location where the system will stock the finished products."), 'address_id': fields.many2one('res.partner.address', 'Destination Address', help="Optional address where goods are to be delivered, specifically used for allotment"),
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
'tracking_id': fields.many2one('stock.tracking', 'Pack', select=True, help="This is the code that will be put on the logistical unit: pallet, box, pack."),
'tracking_id': fields.many2one('stock.tracking', 'Pack', select=True, help="Logistical shipping unit: pallet, box, pack ..."),
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
'move_dest_id': fields.many2one('stock.move', 'Dest. Move'), 'move_history_ids': fields.many2many('stock.move', 'stock_move_history_ids', 'parent_id', 'child_id', 'Move History'), 'move_history_ids2': fields.many2many('stock.move', 'stock_move_history_ids', 'child_id', 'parent_id', 'Move History'),
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Optional: next stock move when chaining them"), 'move_history_ids': fields.many2many('stock.move', 'stock_move_history_ids', 'parent_id', 'child_id', 'Move History (child moves)'), 'move_history_ids2': fields.many2many('stock.move', 'stock_move_history_ids', 'child_id', 'parent_id', 'Move History (parent moves)'),
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
if not context: context={} group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Administration / Configuration','Administration / Access Rights'))]) user_obj = self.pool.get('res.users') group=[] user_rec = user_obj.read(cr, uid, uid) for move in self.browse(cr, uid, ids): if move.state=='done': group=[i for i in group_id if (i and (i not in user_rec['groups_id']))] if group: raise osv.except_osv(_('Error!'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves in Done state (except by the Administrator ' ))
if uid != 1: for move in self.browse(cr, uid, ids): if move.state == 'done': frozen_fields = set(['product_qty', 'product_uom', 'product_uos_qty', 'product_uos', 'location_id', 'location_dest_id', 'product_id']) if frozen_fields.intersection(vals): raise osv.except_osv(_('Operation forbidden'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves that have already been processed (except by the Administrator)'))
def write(self, cr, uid, ids, vals, context=None): if not context: context={} group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Administration / Configuration','Administration / Access Rights'))]) user_obj = self.pool.get('res.users') group=[] user_rec = user_obj.read(cr, uid, uid) for move in self.browse(cr, uid, ids): if move.state=='done': group=[i for i in group_id if (i and (i not in user_rec['groups_id']))] if group: raise osv.except_osv(_('Error!'), _('Quantities, UoMs, Products and Locations cannot be modified on stock moves in Done state (except by the Administrator ' )) return super(stock_move, self).write(cr, uid, ids, vals, context=context)
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values"""
def _find_next_stage(self, cr, uid, stage_list, index, current_seq, stage_pool, context=None): if index + 1 == len(stage_list): return False print "cul" print index next_stage_id = stage_list[index + 1] next_stage = stage_pool.browse(cr, uid, next_stage_id, context=context) if not next_stage: return False next_seq = next_stage.sequence if (abs(next_seq - current_seq)) >= 1: print next_stage return next_stage else : return _find_next_stage(cr, uid, stage_list, index + 1, current_seq, stage_pool) def stage_change(self, cr, uid, ids, context=None, order='sequence'):
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
stages = stage_pool.search(cr, uid, domain, order='sequence')
stages = stage_pool.search(cr, uid, domain, order=order) current_seq = case.stage_id.sequence
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence
print stages print "call" next_stage = self._find_next_stage(cr, uid, stages, index, current_seq, stage_pool, context=context)
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability})
next_stage_id = next_stage.id data = {'stage_id': next_stage.id} if next_stage.on_change: data.update({'probability': next_stage.probability})
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
return next_stage
return next_stage_id def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" return self.stage_change(cr, uid, ids, context=context, order='sequence')
def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') current_seq = False for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] current_seq = case.stage_id.sequence if next_stage: stage = stage_pool.browse(cr, uid, next_stage, context=context) next_seq = stage.sequence if current_seq and (next_seq - current_seq) >= 1: data = {'stage_id': next_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage
if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') for case in self.browse(cr, uid, ids, context): prev_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = 0 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index == 0: return False else: prev_stage = stages[index - 1] current_seq = case.stage_id.sequence if prev_stage: stage = stage_pool.browse(cr, uid, prev_stage, context=context) prev_seq = stage.sequence if current_seq and (prev_seq - current_seq) <= 1: data = {'stage_id': prev_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return prev_stage
return self.stage_change(cr, uid, ids, context=context, order='sequence desc')
def stage_previous(self, cr, uid, ids, context=None): """This function computes previous stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') stage_type = context and context.get('stage_type','') for case in self.browse(cr, uid, ids, context): prev_stage = False data = {} domain = [('type', '=', stage_type),('section_ids', '=', case.section_id.id)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = 0 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index == 0: return False else: prev_stage = stages[index - 1] current_seq = case.stage_id.sequence if prev_stage: stage = stage_pool.browse(cr, uid, prev_stage, context=context) prev_seq = stage.sequence if current_seq and (prev_seq - current_seq) <= 1: data = {'stage_id': prev_stage} if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return prev_stage
def onchange_multi_level_bom(self, cr, uid, ids, multi_level_bom, context={}): """ Changes multi_level_bom. @param multi_level_bom: Changed multi_level_bom @return: Dictionary of changed values """ bom_ids = ids and ids[0] bom = self.browse(cr, uid, bom_ids) line_ids = bom and map(lambda x:x.id, bom.bom_lines) if multi_level_bom: self.write(cr, uid, line_ids, {'multi_level_bom': multi_level_bom}) return {'value': {'bom_lines': line_ids}} else: self.write(cr, uid, line_ids, {'multi_level_bom': multi_level_bom}) return {'value': {}}
def onchange_product_id(self, cr, uid, ids, product_id, name, context={}): """ Changes UoM and name if product_id changes. @param name: Name of the field @param product_id: Changed product_id @return: Dictionary of changed values """ if product_id: prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0] v = {'product_uom': prod.uom_id.id} if not name: v['name'] = prod.name return {'value': v} return {}
message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals['origin'] or "n/a") + "' "+ _("is created.")
message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals.get('name', 'n/a')) + _(" with origin")+" '" + vals.get('origin', 'n/a') + "' "+ _("is created.")
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) type_list = { 'out':_('Packing List'), 'in':_('Reception'), 'internal': _('Internal picking'), 'delivery': _('Delivery order') } new_id = super(stock_picking, self).create(cr, user, vals, context) if not vals.get('auto_picking', False): message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals['name'] or "n/a") + _(" with origin")+" '" + (vals['origin'] or "n/a") + "' "+ _("is created.") self.log(cr, user, new_id, message) return new_id
hrs = float(planned / occupation_rate)
hrs = float(planned / float(occupation_rate))
def onchange_planned(self, cr, uid, ids, project, user_id=False, planned=0.0, effective=0.0, date_start=None, occupation_rate=0.0): result = {} if date_start: resource_pool = self.pool.get('resource.resource') project_pool = self.pool.get('project.project') resource_calendar = self.pool.get('resource.calendar') dt_start = mx.DateTime.strptime(date_start, '%Y-%m-%d %H:%M:%S') resource_id = resource_pool.search(cr, uid, [('user_id','=',user_id)]) if resource_id: resource_obj = resource_pool.browse(cr, uid, resource_id)[0] hrs = planned / (float(occupation_rate) * resource_obj.time_efficiency) calendar_id = resource_obj.calendar_id.id else: hrs = float(planned / occupation_rate) calendar_id = project_pool.browse(cr, uid, project).resource_calendar_id .id work_times = resource_calendar.interval_get(cr, uid, calendar_id or False, dt_start, hrs or 0.0, resource_id or False) result['date_end'] = work_times[-1][1].strftime('%Y-%m-%d %H:%M:%S') result['remaining_hours'] = planned - effective return {'value' : result}
'get_start_date': self.get_start_date, 'get_end_date': self.get_end_date,
'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date,
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_period, 'sum_credit_period': self._sum_credit_period, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_date': self.get_start_date, 'get_end_date': self.get_end_date, 'get_filter': self._get_filter })
qty)[res['base_pricelist_id']]
qty, context=context)[res['base_pricelist_id']]
def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst
journal_data = obj_journal.browse(cr, uid, context['journal'])
journal_data = journal_obj.browse(cr, uid, context['journal'])
def _default_get(self, cr, uid, fields, context={}): if not context.get('journal_id', False) and context.get('search_default_journal_id', False): context['journal_id'] = context.get('search_default_journal_id') account_obj = self.pool.get('account.account') period_obj = self.pool.get('account.period') journal_obj = self.pool.get('account.journal') move_obj = self.pool.get('account.move') tax_obj = self.pool.get('account.tax') fiscal_pos_obj = self.pool.get('account.fiscal.position') partner_obj = self.pool.get('res.partner') currency_obj = self.pool.get('res.currency') context = self.convert_to_period(cr, uid, context) # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context) # Starts: Manual entry from account.move form if context.get('lines',[]): total_new = 0.00 for i in context['lines']: if i[2]: total_new += (i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00) for item in i[2]: data[item] = i[2][item] if context['journal']: journal_data = obj_journal.browse(cr, uid, context['journal']) if journal_data.type == 'purchase': if total_new > 0: account = journal_data.default_credit_account_id else: account = journal_data.default_debit_account_id else: if total_new > 0: account = journal_data.default_credit_account_id else: account = journal_data.default_debit_account_id if account and ((not fields) or ('debit' in fields) or ('credit' in fields)) and 'partner_id' in data and (data['partner_id']): part = partner_obj.browse(cr, uid, data['partner_id']) account = fiscal_pos_obj.map_account(cr, uid, part and part.property_account_position or False, account.id) account = account_obj.browse(cr, uid, account) data['account_id'] = account.id
to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month,
to_char(date_end, 'YYYY') as name, to_char(date_end, 'MM') as month,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" create or replace view report_project_task_user as ( select min(t.id) as id, to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month, count(distinct t.id) as task_closed, t.user_id, t.project_id, sum(planned_hours) as hours_planned, to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days, sum(w.hours) as hours_effective, ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay from project_task t left join project_task_work w on (t.id=w.task_id) where t.state='done' group by to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),t.user_id,project_id ) """)
to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days,
to_char(avg(date_end::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" create or replace view report_project_task_user as ( select min(t.id) as id, to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month, count(distinct t.id) as task_closed, t.user_id, t.project_id, sum(planned_hours) as hours_planned, to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days, sum(w.hours) as hours_effective, ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay from project_task t left join project_task_work w on (t.id=w.task_id) where t.state='done' group by to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),t.user_id,project_id ) """)
to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),t.user_id,project_id
to_char(date_end, 'YYYY'),to_char(date_end, 'MM'),t.user_id,project_id
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task_user') cr.execute(""" create or replace view report_project_task_user as ( select min(t.id) as id, to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month, count(distinct t.id) as task_closed, t.user_id, t.project_id, sum(planned_hours) as hours_planned, to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days, sum(w.hours) as hours_effective, ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay from project_task t left join project_task_work w on (t.id=w.task_id) where t.state='done' group by to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),t.user_id,project_id ) """)
to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month,
to_char(date_end, 'YYYY') as name, to_char(date_end, 'MM') as month,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task') cr.execute(""" create or replace view report_project_task as ( select min(t.id) as id, to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month, count(distinct t.id) as task_closed, t.project_id, sum(planned_hours) as hours_planned, to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days, sum(w.hours) as hours_effective, ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay from project_task t left join project_task_work w on (t.id=w.task_id) where t.state='done' group by to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),project_id ) """)
to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
to_char(avg(date_end::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task') cr.execute(""" create or replace view report_project_task as ( select min(t.id) as id, to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month, count(distinct t.id) as task_closed, t.project_id, sum(planned_hours) as hours_planned, to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days, sum(w.hours) as hours_effective, ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay from project_task t left join project_task_work w on (t.id=w.task_id) where t.state='done' group by to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),project_id ) """)
to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),project_id
to_char(date_end, 'YYYY'),to_char(date_end, 'MM'),project_id
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'report_project_task') cr.execute(""" create or replace view report_project_task as ( select min(t.id) as id, to_char(date_close, 'YYYY') as name, to_char(date_close, 'MM') as month, count(distinct t.id) as task_closed, t.project_id, sum(planned_hours) as hours_planned, to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days, sum(w.hours) as hours_effective, ((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay from project_task t left join project_task_work w on (t.id=w.task_id) where t.state='done' group by to_char(date_close, 'YYYY'),to_char(date_close, 'MM'),project_id ) """)
factor = production.product_qty * production.product_uom.factor / bom_point.product_uom.factor
factor = production.product_qty * production.product_uom.factor_inv / bom_point.product_uom.factor
def action_compute(self, cr, uid, ids, properties=[]): """ Computes bills of material of a product. @param properties: List containing dictionaries of properties. @return: No. of products. """ results = [] bom_obj = self.pool.get('mrp.bom') prod_line_obj = self.pool.get('mrp.production.product.line') workcenter_line_obj = self.pool.get('mrp.production.workcenter.line') for production in self.browse(cr, uid, ids): cr.execute('delete from mrp_production_product_line where production_id=%s', (production.id,)) cr.execute('delete from mrp_production_workcenter_line where production_id=%s', (production.id,)) bom_point = production.bom_id bom_id = production.bom_id.id if not bom_point: bom_id = bom_obj._bom_find(cr, uid, production.product_id.id, production.product_uom.id, properties) if bom_id: bom_point = bom_obj.browse(cr, uid, bom_id) routing_id = bom_point.routing_id.id or False self.write(cr, uid, [production.id], {'bom_id': bom_id, 'routing_id': routing_id})
self.pool.get('stock.move').action_done(cr, uid, new_moves)
def action_production_end(self, cr, uid, ids):
self.pool.get('stock.move').action_done(cr, uid, move_ids)
def action_production_end(self, cr, uid, ids):
if not default.get('name',False): default['name'] = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking')
picking_obj = self.browse(cr, uid, [id], context)[0] if ('name' not in default) or (picking_obj.get('name')=='/'): seq_obj_name = 'stock.picking.' + picking_obj.type default['name'] = self.pool.get('ir.sequence').get(cr, uid, seq_obj_name)
def copy(self, cr, uid, id, default=None, context={}): if default is None: default = {} default = default.copy() if not default.get('name',False): default['name'] = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking') return super(stock_picking, self).copy(cr, uid, id, default, context)
return_false = False
for id in ids: res[id] = {}.fromkeys(name, 0)
def _user_left_days(self, cr, uid, ids, name, args, context={}): res = {} return_false = False if context and context.has_key('employee_id'): if not context['employee_id']: return_false = True employee_id = context['employee_id'] else: employee_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)]) if employee_ids: employee_id = employee_ids[0] else: return_false = True if employee_id: res = self.get_days(cr, uid, ids, employee_id, return_false, context=context) return res
'<a href="
+ \
def insert_pad_link(self, output): # Insert the link on the line right after the link to open the # attachment form form_opener_insertion = output.index( '\n', output.index(self.ADD_ATTACHMENT_BUTTON)) + 1 output = output[:form_opener_insertion] + \ '<a href="#" id="add-pad" class="button-a">${_("Pad")}</a>\n' + \ output[form_opener_insertion:] return output
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.project.bug')]"),
domain="['|',('section_id','=',section_id),('section_id','=',False), ('object_id.model', '=', 'crm.lead')]"),
def _compute_day(self, cr, uid, ids, fields, args, context={}): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
print "<<<<<<<<<<<<<<s<<<<<<<<"
def action_done(self, cr, uid, ids, context={}): track_flag = False picking_ids = [] lines=[] sale=[] purchase=[] product_uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') product_obj=self.pool.get('product.product') move_obj = self.pool.get('account.move') for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass # self.action_done(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
lines=sale[0] +purchase[0]
def action_done(self, cr, uid, ids, context={}): track_flag = False picking_ids = [] lines=[] sale=[] purchase=[] product_uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') product_obj=self.pool.get('product.product') move_obj = self.pool.get('account.move') for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass # self.action_done(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
'line_id':lines,
'line_id':(purchase and purchase[0]) or( sale and sale[0]),
def action_done(self, cr, uid, ids, context={}): track_flag = False picking_ids = [] lines=[] sale=[] purchase=[] product_uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') product_obj=self.pool.get('product.product') move_obj = self.pool.get('account.move') for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass # self.action_done(cr, uid, [move.move_dest_id.id]) if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
cr.execute("select count(id) from email_server where user='%s' and password='%s'", (vals['user'], vals['password']))
cr.execute("select count(id) from email_server where user=%s and password=%s", (vals['user'], vals['password']))
def check_duplicate(self, cr, uid, ids):
res = super(crm_send_new_email, self).default_get(cr, uid, fields, context=context)
res = super(crm_send_new_email2, self).default_get(cr, uid, fields, context=context)
def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {}
amount = currency_obj.compute(cr, uid, line.currency_id.id,
amount = currency_obj.compute(cursor, user, line.currency_id.id,
def populate_statement(self, cr, uid, ids, context=None):
else: if line.debit > 0: amount=line.debit elif line.credit > 0: amount=-line.credit
elif (line.invoice and line.invoice.currency_id.id <> statement.currency.id): amount = currency_obj.compute(cursor, user, line.invoice.currency_id.id, statement.currency.id, amount, context=ctx)
def populate_statement(self, cr, uid, ids, context=None):
users = self.pool.get('res_users')
users = self.pool.get('res.users')
def set_default_menu(self, cr, uid, menu, context=None): users = self.pool.get('res_users') users.write(cr, uid, users.search(cr, uid, [('action_id','=','Setup')], context=context), {'action_id': menu.id}, context=context) users.write(cr, uid, users.search(cr, uid, [('menu_id','=','Setup')], context=context), {'menu_id': menu.id}, context=context)
'factor': fields.float('Ratio', required=True,digits=(12, 6),
'factor': fields.float('Ratio', required=True,digits=(12, 12),
def create(self, cr, uid, data, context={}): if 'factor_inv' in data: if data['factor_inv'] <> 1: data['factor'] = self._compute_factor_inv(data['factor_inv']) del(data['factor_inv']) return super(product_uom, self).create(cr, uid, data, context)
res = dict.fromkeys(ids, {name: 0})
res = dict.fromkeys(ids, {'leaves_taken': 0, 'remaining_leaves': 0, 'max_leaves': 0})
def _user_left_days(self, cr, uid, ids, name, args, context=None): if context is None: context = {} return_false = False employee_id = False res = {}
company_id = period_obj.browse(cr, uid, data['form']['period_from'], context=context).company_id
company_id = period_obj.browse(cr, uid, data['form']['period_from'], context=context).company_id.id
def _build_contexts(self, cr, uid, ids, data, context=None): if context is None: context = {} result = {} period_obj = self.pool.get('account.period') fiscal_obj = self.pool.get('account.fiscalyear') result['fiscalyear'] = 'fiscalyear_id' in data['form'] and data['form']['fiscalyear_id'] or False result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False result['chart_account_id'] = 'chart_account_id' in data['form'] and data['form']['chart_account_id'] or False result_initial_bal = result.copy() if data['form']['filter'] == 'filter_date': result['date_from'] = data['form']['date_from'] result['date_to'] = data['form']['date_to'] result_initial_bal['date_from'] = '0001-01-01' result_initial_bal['date_to'] = (datetime.datetime.strptime(data['form']['date_from'], "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') elif data['form']['filter'] == 'filter_period': if not data['form']['period_from'] or not data['form']['period_to']: raise osv.except_osv(_('Error'),_('Select a starting and an ending period')) company_id = period_obj.browse(cr, uid, data['form']['period_from'], context=context).company_id result['periods'] = period_obj.build_ctx_periods(cr, uid, data['form']['period_from'], data['form']['period_to']) first_period = self.pool.get('account.period').search(cr, uid, [('company_id', '=', company_id)], order='date_start', limit=1)[0] result_initial_bal['periods'] = period_obj.build_ctx_periods(cr, uid, first_period, data['form']['period_from']) else: if data['form']['fiscalyear_id']: fiscal_date_start = fiscal_obj.browse(cr, uid, [data['form']['fiscalyear_id']], context=context)[0].date_start result_initial_bal['empty_fy_allow'] = True #Improve me => there should be something generic in account.move.line -> query get result_initial_bal['fiscalyear'] = fiscal_obj.search(cr, uid, [('date_stop', '<', fiscal_date_start), ('state', '=', 'draft')], context=context) result_initial_bal['date_from'] = '0001-01-01' result_initial_bal['date_to'] = (datetime.datetime.strptime(fiscal_date_start, "%Y-%m-%d") + timedelta(days=-1)).strftime('%Y-%m-%d') return result, result_initial_bal
raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name)))
raise osv.except_osv(_('Error !'), (_('User %s does not have rights to access %s journal !') % (statement.user_id.name, statement.journal_id.name)))
def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ if context is None: context = {} statement_pool = self.pool.get('account.bank.statement') for statement in statement_pool.browse(cr, uid, ids, context=context): vals = {} force_allow = context.get('force_allow',False) if not force_allow and not self._user_allow(cr, uid, statement.id, context=context): raise osv.except_osv(_('Error !'), _('User %s does not have rights to access %s journal !' % (statement.user_id.name, statement.journal_id.name)))
type1 = context['type'] or 'move_history_ids'
type1 = context['type'] or 'move_history_ids2'
def action_traceability(self, cr, uid, ids, context={}): """ It traces the information of a product @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: A dictionary of values """
'name': ((type1=='move_history_ids') and 'Donwstream Traceability') or 'Upstream Traceability',
'name': ((type1=='move_history_ids2') and 'Upstream Traceability') or 'Downstream Traceability',
def action_traceability(self, cr, uid, ids, context={}): """ It traces the information of a product @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of IDs selected @param context: A standard dictionary @return: A dictionary of values """
self.pool.get('stock.move').action_confirm(cr, uid, [move]) self.pool.get('stock.move').force_assign(cr,uid, [move])
todo_moves.append(move) self.pool.get('stock.move').action_confirm(cr, uid, todo_moves) self.pool.get('stock.move').force_assign(cr, uid, todo_moves)
def action_picking_create(self,cr, uid, ids, *args): picking_id = False for order in self.browse(cr, uid, ids): loc_id = order.partner_id.property_stock_supplier.id istate = 'none' if order.invoice_method=='picking': istate = '2binvoiced' pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in') picking_id = self.pool.get('stock.picking').create(cr, uid, { 'name': pick_name, 'origin': order.name+((order.origin and (':'+order.origin)) or ''), 'type': 'in', 'address_id': order.dest_address_id.id or order.partner_address_id.id, 'invoice_state': istate, 'purchase_id': order.id, 'company_id': order.company_id.id, }) for order_line in order.order_line: if not order_line.product_id: continue if order_line.product_id.product_tmpl_id.type in ('product', 'consu'): dest = order.location_id.id move = self.pool.get('stock.move').create(cr, uid, { 'name': 'PO:'+order_line.name, 'product_id': order_line.product_id.id, 'product_qty': order_line.product_qty, 'product_uos_qty': order_line.product_qty, 'product_uom': order_line.product_uom.id, 'product_uos': order_line.product_uom.id, 'date_planned': order_line.date_planned, 'location_id': loc_id, 'location_dest_id': dest, 'picking_id': picking_id, 'move_dest_id': order_line.move_dest_id.id, 'state': 'draft', 'purchase_line_id': order_line.id, 'company_id': order.company_id.id, }) if order_line.move_dest_id: self.pool.get('stock.move').write(cr, uid, [order_line.move_dest_id.id], {'location_id':order.location_id.id}) self.pool.get('stock.move').action_confirm(cr, uid, [move]) self.pool.get('stock.move').force_assign(cr,uid, [move]) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) return picking_id
self.write(cr, uid, move.id, {'state':'assigned'})
self.write(cr, uid, [move.id], {'state':'assigned'})
def check_assign(self, cr, uid, ids, context=None): """ Checks the product type and accordingly writes the state. @return: No. of moves done """ done = [] count = 0 pickings = {} if context is None: context = {} for move in self.browse(cr, uid, ids, context=context): if move.product_id.type == 'consu': if move.state in ('confirmed', 'waiting'): done.append(move.id) pickings[move.picking_id.id] = 1 continue if move.state in ('confirmed', 'waiting'): res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id}) if res: #_product_available_test depends on the next status for correct functioning #the test does not work correctly if the same product occurs multiple times #in the same order. This is e.g. the case when using the button 'split in two' of #the stock outgoing form self.write(cr, uid, move.id, {'state':'assigned'}) done.append(move.id) pickings[move.picking_id.id] = 1 r = res.pop(0) cr.execute('update stock_move set location_id=%s, product_qty=%s where id=%s', (r[1], r[0], move.id))
ret = super(users,self).login(db, login, password)
ret = super(users,self).login(db, login, password) tools.debug(ret)
def login(self, db, login, password): ret = super(users,self).login(db, login, password) if ret: return ret pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() action_obj = pool.get('ir.actions.actions') cr.execute(""" SELECT id, company, ldap_server, ldap_server_port, ldap_binddn, ldap_password, ldap_filter, ldap_base, \"user\", create_user FROM res_company_ldap WHERE ldap_server != '' and ldap_binddn != '' ORDER BY sequence""") for res_company_ldap in cr.dictfetchall(): try: l = ldap.open(res_company_ldap['ldap_server'], res_company_ldap['ldap_server_port']) if l.simple_bind_s(res_company_ldap['ldap_binddn'], res_company_ldap['ldap_password']): base = res_company_ldap['ldap_base'] scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap['ldap_filter'], (login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if not result_data: continue if result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] name = result_data[0][1]['cn'][0] if l.bind_s(dn, passwd): l.unbind() cr.execute("SELECT id FROM res_users WHERE login=%s",(tools.ustr(login),)) res = cr.fetchone() if res: cr.close() return res[0] if not res_company_ldap['create_user']: continue action_id = action_obj.search(cr, 1, [('usage', '=', 'menu')])[0] if res_company_ldap['user']: res = self.copy(cr, 1, res_company_ldap['user'], default={'active': True}) self.write(cr, 1, res, { 'name': name, 'login': login.encode('utf-8'), 'company_id': res_company_ldap['company'], }) else: res = self.create(cr, 1, { 'name': name, 'login': login.encode('utf-8'), 'company_id': res_company_ldap['company'], 'action_id': action_id, 'menu_id': action_id, }) cr.commit() cr.close() return res l.unbind() except Exception, e: continue cr.close() return False
SELECT id, company, ldap_server, ldap_server_port, ldap_binddn, ldap_password, ldap_filter, ldap_base, \"user\", create_user FROM res_company_ldap
SELECT id, company, ldap_server, ldap_server_port, ldap_binddn, ldap_password, ldap_filter, ldap_base, "user", create_user FROM res_company_ldap
def login(self, db, login, password): ret = super(users,self).login(db, login, password) if ret: return ret pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() action_obj = pool.get('ir.actions.actions') cr.execute(""" SELECT id, company, ldap_server, ldap_server_port, ldap_binddn, ldap_password, ldap_filter, ldap_base, \"user\", create_user FROM res_company_ldap WHERE ldap_server != '' and ldap_binddn != '' ORDER BY sequence""") for res_company_ldap in cr.dictfetchall(): try: l = ldap.open(res_company_ldap['ldap_server'], res_company_ldap['ldap_server_port']) if l.simple_bind_s(res_company_ldap['ldap_binddn'], res_company_ldap['ldap_password']): base = res_company_ldap['ldap_base'] scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap['ldap_filter'], (login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if not result_data: continue if result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] name = result_data[0][1]['cn'][0] if l.bind_s(dn, passwd): l.unbind() cr.execute("SELECT id FROM res_users WHERE login=%s",(tools.ustr(login),)) res = cr.fetchone() if res: cr.close() return res[0] if not res_company_ldap['create_user']: continue action_id = action_obj.search(cr, 1, [('usage', '=', 'menu')])[0] if res_company_ldap['user']: res = self.copy(cr, 1, res_company_ldap['user'], default={'active': True}) self.write(cr, 1, res, { 'name': name, 'login': login.encode('utf-8'), 'company_id': res_company_ldap['company'], }) else: res = self.create(cr, 1, { 'name': name, 'login': login.encode('utf-8'), 'company_id': res_company_ldap['company'], 'action_id': action_id, 'menu_id': action_id, }) cr.commit() cr.close() return res l.unbind() except Exception, e: continue cr.close() return False
if l.bind_s(dn, passwd):
if l.bind_s(dn, password):
def login(self, db, login, password): ret = super(users,self).login(db, login, password) if ret: return ret pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() action_obj = pool.get('ir.actions.actions') cr.execute(""" SELECT id, company, ldap_server, ldap_server_port, ldap_binddn, ldap_password, ldap_filter, ldap_base, \"user\", create_user FROM res_company_ldap WHERE ldap_server != '' and ldap_binddn != '' ORDER BY sequence""") for res_company_ldap in cr.dictfetchall(): try: l = ldap.open(res_company_ldap['ldap_server'], res_company_ldap['ldap_server_port']) if l.simple_bind_s(res_company_ldap['ldap_binddn'], res_company_ldap['ldap_password']): base = res_company_ldap['ldap_base'] scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap['ldap_filter'], (login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if not result_data: continue if result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] name = result_data[0][1]['cn'][0] if l.bind_s(dn, passwd): l.unbind() cr.execute("SELECT id FROM res_users WHERE login=%s",(tools.ustr(login),)) res = cr.fetchone() if res: cr.close() return res[0] if not res_company_ldap['create_user']: continue action_id = action_obj.search(cr, 1, [('usage', '=', 'menu')])[0] if res_company_ldap['user']: res = self.copy(cr, 1, res_company_ldap['user'], default={'active': True}) self.write(cr, 1, res, { 'name': name, 'login': login.encode('utf-8'), 'company_id': res_company_ldap['company'], }) else: res = self.create(cr, 1, { 'name': name, 'login': login.encode('utf-8'), 'company_id': res_company_ldap['company'], 'action_id': action_id, 'menu_id': action_id, }) cr.commit() cr.close() return res l.unbind() except Exception, e: continue cr.close() return False
pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor()
cr = pooler.get_db(db).cursor()
def check(self, db, uid, passwd): try: return super(users,self).check(db, uid, passwd) except: # AccessDenied pass pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() user = self.browse(cr, 1, uid) if user and user.company_id.ldaps: for res_company_ldap in user.company_id.ldaps: try: l = ldap.open(res_company_ldap.ldap_server, res_company_ldap.ldap_server_port) if l.simple_bind_s(res_company_ldap.ldap_binddn, res_company_ldap.ldap_password): base = res_company_ldap.ldap_base scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap.ldap_filter, (user.login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if result_data and result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] name = result_data[0][1]['cn'] if l.bind_s(dn, passwd): l.unbind() self._uid_cache.setdefault(db, {})[uid] = passwd cr.close() return True l.unbind() except Exception, e: pass cr.close() raise security.ExceptionNoTb('AccessDenied')
name = result_data[0][1]['cn']
def check(self, db, uid, passwd): try: return super(users,self).check(db, uid, passwd) except: # AccessDenied pass pool = pooler.get_pool(db) cr = pooler.get_db(db).cursor() user = self.browse(cr, 1, uid) if user and user.company_id.ldaps: for res_company_ldap in user.company_id.ldaps: try: l = ldap.open(res_company_ldap.ldap_server, res_company_ldap.ldap_server_port) if l.simple_bind_s(res_company_ldap.ldap_binddn, res_company_ldap.ldap_password): base = res_company_ldap.ldap_base scope = ldap.SCOPE_SUBTREE filter = filter_format(res_company_ldap.ldap_filter, (user.login,)) retrieve_attributes = None result_id = l.search(base, scope, filter, retrieve_attributes) timeout = 60 result_type, result_data = l.result(result_id, timeout) if result_data and result_type == ldap.RES_SEARCH_RESULT and len(result_data) == 1: dn = result_data[0][0] name = result_data[0][1]['cn'] if l.bind_s(dn, passwd): l.unbind() self._uid_cache.setdefault(db, {})[uid] = passwd cr.close() return True l.unbind() except Exception, e: pass cr.close() raise security.ExceptionNoTb('AccessDenied')
'res_users': menu.res_model,
'res_model': menu.res_model,
def menu(self, cr, uid, ids, context=None): menu = self.get_default_menu(cr, uid, context=context) self.set_default_menu(cr, uid, menu, context=context)
'description': fields.text('Description'),
'description': fields.text('Note'),
def _compute_day(self, cr, uid, ids, fields, args, context={}): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
manager = self.pool.get('hr.department').browse(cr, uid, department_id).manager_id.id return {'value': {'parent_id':manager or False}}
if not department_id: return {'value':{'parent_id': False}} manager = self.pool.get('hr.department').browse(cr, uid, department_id).manager_id return {'value': {'parent_id':manager and manager.id or False}}
def onchange_department(self, cr, uid, ids, department_id, context=None): manager = self.pool.get('hr.department').browse(cr, uid, department_id).manager_id.id return {'value': {'parent_id':manager or False}}
'photo': fields.binary('Photo')
'photo': fields.binary('Photo'), 'passport_id':fields.char('Passport', size=64)
def job_open(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'open'}) return True
self.res_find_all = parent.res_find_all
if isinstance(parent, node_res_dir): self.res_find_all = parent.res_find_all else: self.res_find_all = False
def __init__(self, path, dir_id, parent, context, res_model, res_bo, res_id = None): super(node_res_obj,self).__init__(path, parent,context) assert parent #todo: more info from dirr self.dir_id = dir_id self.mimetype = 'application/x-directory' # 'httpd/unix-directory' self.create_date = parent.create_date # TODO: the write date should be MAX(file.write).. self.write_date = parent.write_date self.content_length = 0 self.uidperms = parent.uidperms & 15 self.unixperms = 040000 | _uid2unixperms(self.uidperms, True) self.uuser = parent.uuser self.ugroup = parent.ugroup self.res_model = res_model self.domain = parent.domain self.displayname = path self.dctx_dict = parent.dctx_dict self.res_find_all = parent.res_find_all if res_bo: self.res_id = res_bo.id dc2 = self.context.context.copy() dc2.update(self.dctx) dc2['res_model'] = res_model dc2['res_id'] = res_bo.id dc2['this'] = res_bo for fld,expr in self.dctx_dict.items(): try: self.dctx[fld] = safe_eval(expr, dc2) except Exception,e: print "Cannot eval %s for %s" % (expr, fld) print e pass else: self.res_id = res_id
res.append(klass(res_name, dir_id=self.dir_id, parent=self, context=self.context, res_model=self.res_model, res_bo=bo))
rnode = klass(res_name, dir_id=self.dir_id, parent=self, context=self.context, res_model=self.res_model, res_bo=bo) rnode.res_find_all = self.res_find_all res.append(rnode)
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = bo, res_id = self.res_id))
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
where5 = where4 + [('ressource_id','=',0)]
where5 = where4 + ['|', ('ressource_id','=',0), ('ressource_id','=',self.res_id)]
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
where5 = where4 + [('ressource_id','=',self.res_id)] dirids = dirids + dirobj.search(cr,uid, where5)
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
rnode = klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = bo, res_id = self.res_id) rnode.res_find_all = dirr.resource_find_all res.append(rnode)
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
res.append(klass(dirr.name, self, self.context, dirr, {'active_id': self.res_id}))
rnode = klass(dirr.name, self, self.context, dirr, {'active_id': self.res_id}) rnode.res_find_all = dirr.resource_find_all res.append(rnode)
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
'parent_id' : False
'parent_id' : False, 'resource_find_all': False,
def create_child_collection(self, cr, objname): dirobj = self.context._dirobj is_allowed = self.check_perms(2) if not is_allowed: raise IOError(errno.EPERM,"Permission denied")
'factor': fields.float('Ratio', digits_compute=dp.get_precision('Product UoM'), required=True,
'factor': fields.float('Ratio', required=True,digits=(12, 6),
def create(self, cr, uid, data, context={}): if 'factor_inv' in data: if data['factor_inv'] <> 1: data['factor'] = self._compute_factor_inv(data['factor_inv']) del(data['factor_inv']) return super(product_uom, self).create(cr, uid, data, context)
emails = [obj.email_to]
emails = re.findall(r'([^ ,<@]+@[^> ,]+)', obj.email_to or '')
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """ hist_obj = self.pool.get('mailgate.message')
res.update({'reply_to': case.section_id.reply_to})
res.update({'reply_to': case.section_id.reply_to or ''})
def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('mailgate.message') res_ids = context and context.get('active_ids', []) or []
'product_packaging': False
'product_packaging': False, 'price_unit': 0.0,
def _number_packages(self, cr, uid, ids, field_name, arg, context=None): res = {} for line in self.browse(cr, uid, ids, context=context): try: res[line.id] = int((line.product_uom_qty+line.product_packaging.qty-0.0001) / line.product_packaging.qty) except: res[line.id] = 1 return res
'context':{'date_from':product_margin_obj.from_date,'date_to':product_margin_obj.to_date,'invoice_state' : product_margin_obj.invoice_state},
'context': context,
def action_open_window(self, cr, uid, ids, context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the ID or list of IDs if we want more than one
ids = move_line_pool.search(cr, uid, [('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)], context=context)
ids = move_line_pool.search(cr, uid, [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id)], context=context)
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
prod_obj = self.pool.get('product.template') location_obj = self.pool.get('stock.location') lot_obj = self.pool.get('stock.report.prodlots') move_obj = self.pool.get('account.move') move_line_obj = self.pool.get('account.move.line') data_obj = self.pool.get('ir.model.data') res = self.read(cr, uid, ids[0], ['new_price']) new_price = res.get('new_price',[]) data = prod_obj.browse(cr, uid, rec_id) diff = data.standard_price - new_price prod_obj.write(cr, uid, rec_id, {'standard_price': new_price}) loc_ids = location_obj.search(cr, uid, [('account_id','<>',False),('usage','=','internal')]) lot_ids = lot_obj.search(cr, uid, [('location_id', 'in', loc_ids),('product_id','=',rec_id)]) qty = 0 debit = 0.0 credit = 0.0 stock_input_acc = data.property_stock_account_input.id or data.categ_id.property_stock_account_input_categ.id stock_output_acc = data.property_stock_account_output.id or data.categ_id.property_stock_account_output_categ.id for lots in lot_obj.browse(cr, uid, lot_ids): qty += lots.name if stock_input_acc and stock_output_acc and lot_ids: move_id = move_obj.create(cr, uid, {'journal_id': data.categ_id.property_stock_journal.id}) if diff > 0: credit = qty * diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_input_acc, 'credit': credit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): credit = lots.name * diff move_line_obj.create(cr, uid, { 'name': 'Expense', 'account_id': lots.location_id.account_id.id, 'debit': credit, 'move_id': move_id }) elif diff < 0: debit = qty * -diff move_line_obj.create(cr, uid, { 'name': data.name, 'account_id': stock_output_acc, 'debit': debit, 'move_id': move_id }) for lots in lot_obj.browse(cr, uid, lot_ids): debit = lots.name * -diff move_line_obj.create(cr, uid, { 'name': 'Income', 'account_id': lots.location_id.account_id.id, 'credit': debit, 'move_id': move_id }) else: raise osv.except_osv(_('Warning!'),_('No Change in Price.')) else: pass return {}
assert rec_id, _('Active ID is not set in Context') prod_obj = self.pool.get('product.product') res = self.browse(cr, uid, ids) datas = { 'new_price' : res[0].new_price, 'stock_output_account' : res[0].stock_account_output.id, 'stock_input_account' : res[0].stock_account_input.id, 'stock_journal' : res[0].stock_journal.id } prod_obj.do_change_standard_price(cr, uid, [rec_id], datas, context) return {}
def change_price(self, cr, uid, ids, context): """ Changes the Standard Price of Product. And creates an account move accordingly.
return [(r['id'], r['name'] + ' - ' + r['vat']) \
return [(r['id'], r['name'] or '' + ' - ' + r['vat'] or '') \
def name_get(self, cr, uid, ids, context={}): if not len(ids): return [] return [(r['id'], r['name'] + ' - ' + r['vat']) \ for r in self.read(cr, uid, ids, ['name', 'vat'], context, load='_classic_write')]
attrs.append('string="'+field_it[2]+'"')
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal') if context is None: context = {} result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) if view_type != 'tree': #Remove the toolbar from the form view if view_type == 'form': if result.get('toolbar', False): result['toolbar']['action'] = [] #Restrict the list of journal view in search view if view_type == 'search' and result['fields'].get('journal_id', False): result['fields']['journal_id']['selection'] = journal_pool.name_search(cr, uid, '', [], context=context) return result if context.get('view_mode', False): return result fld = [] fields = {} flds = [] title = "Accounting Entries" #self.view_header_get(cr, uid, view_id, view_type, context) xml = '''<?xml version="1.0"?>\n<tree string="%s" editable="top" refresh="5" on_write="on_create_write" colors="red:state==\'draft\';black:state==\'valid\'">\n\t''' % (title)
'scrum_master_id': fields.many2one('res.users', 'Scrum Manager', required=True,help="The person who is maintains the processes for the product"),
'scrum_master_id': fields.many2one('res.users', 'Scrum Master', required=True,help="The person who is maintains the processes for the product"),
def button_pending(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'pending'}, context=context) return True
self.email_send(cr, uid, ids, email)
self.email_send(cr, uid, ids, meeting_id.sprint_id.scrum_master_id.user_email)
def button_send_to_master(self, cr, uid, ids, context=None): meeting_id = self.browse(cr, uid, ids)[0] user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if meeting_id and meeting_id.sprint_id.scrum_master_id.user_email: self.email_send(cr, uid, ids, email) else: raise osv.except_osv(_('Error !'), _('Please provide email address for scrum master defined on sprint.')) return True
self.email_send(cr,uid,ids,email)
self.email_send(cr,uid,ids,meeting_id.sprint_id.product_owner_id.user_email)
def button_send_product_owner(self, cr, uid, ids, context=None): meeting_id = self.browse(cr, uid, ids)[0] if meeting_id.sprint_id.product_owner_id.user_email: self.email_send(cr,uid,ids,email) else: raise osv.except_osv(_('Error !'), _('Please provide email address for product owner defined on sprint.')) return True
DROP LANGUAGE IF EXISTS plpgsql CASCADE; CREATE LANGUAGE plpgsql ;
def execute(self, cr, uid, ids, context=None): """ This function is used to create contact and address from existing partner address """ obj = self.pool.get("base.contact.installer").browse(cr, uid, uid, context=context) if obj.migrate: cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact; DROP LANGUAGE IF EXISTS plpgsql CASCADE; CREATE LANGUAGE plpgsql ; CREATE OR REPLACE FUNCTION add_to_job() RETURNS TRIGGER AS $contactjob$ DECLARE new_name varchar; new_phonenum varchar; BEGIN IF(TG_OP='INSERT') THEN INSERT INTO res_partner_job(contact_id, address_id, function, state) VALUES(NEW.id, NEW.website::integer,NEW.first_name, 'current'); UPDATE res_partner_contact set first_name=Null, website=Null, active=True where id=NEW.id; END IF; RETURN NEW; END; $contactjob$ LANGUAGE plpgsql; CREATE TRIGGER contactjob AFTER INSERT ON res_partner_contact FOR EACH ROW EXECUTE PROCEDURE add_to_job();""")