rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
for order_id in order_obj.browse(cr, uid, [record_id], context=context): | for order_id in order_obj.browse(cr, uid, [active_id], context=context): | def close_action(self, cr, uid, ids, context): |
obj=order_obj.browse(cr,uid, record_id) | obj=order_obj.browse(cr,uid, active_id) | def close_action(self, cr, uid, ids, context): |
'context ':context and context.get('record_id', False), | 'context ':context and context.get('active_id', False), | def close_action(self, cr, uid, ids, context): |
al.dp as date, | date_trunc('day',al.dp) as date, | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_move') cr.execute(""" CREATE OR REPLACE view report_stock_move AS ( SELECT min(sm_id) as id, al.dp as date, al.curr_year as year, al.curr_month as month, al.curr_day as day, al.curr_day_diff as day_diff, al.curr_day_diff1 as day_diff1, al.curr_day_diff2 as day_diff2, al.location_id as location_id, al.picking_id as picking_id, al.company_id as company_id, al.location_dest_id as location_dest_id, al.product_qty, al.out_qty as product_qty_out, al.in_qty as product_qty_in, al.address_id as partner_id, al.product_id as product_id, al.state as state , al.product_uom as product_uom, al.categ_id as categ_id, coalesce(al.type, 'other') as type, al.stock_journal as stock_journal, sum(al.in_value - al.out_value) as value FROM (SELECT CASE WHEN sp.type in ('out') THEN sum(sm.product_qty * pu.factor) ELSE 0.0 END AS out_qty, CASE WHEN sp.type in ('in') THEN sum(sm.product_qty * pu.factor) ELSE 0.0 END AS in_qty, CASE WHEN sp.type in ('out') THEN sum(sm.product_qty * pu.factor) * pt.standard_price ELSE 0.0 END AS out_value, CASE WHEN sp.type in ('in') THEN sum(sm.product_qty * pu.factor) * pt.standard_price ELSE 0.0 END AS in_value, min(sm.id) as sm_id, sm.date as dp, to_char(date_trunc('day',sm.date), 'YYYY') as curr_year, to_char(date_trunc('day',sm.date), 'MM') as curr_month, to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as curr_day, avg(date(sm.date)-date(sm.create_date)) as curr_day_diff, avg(date(sm.date_expected)-date(sm.create_date)) as curr_day_diff1, avg(date(sm.date)-date(sm.date_expected)) as curr_day_diff2, sm.location_id as location_id, sm.location_dest_id as location_dest_id, sum(sm.product_qty) as product_qty, pt.categ_id as categ_id , sm.address_id as address_id, sm.product_id as product_id, sm.picking_id as picking_id, sm.company_id as company_id, sm.state as state, sm.product_uom as product_uom, sp.type as type, sp.stock_journal_id AS stock_journal FROM stock_move sm LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id) LEFT JOIN product_product pp ON (sm.product_id=pp.id) LEFT JOIN product_uom pu ON (sm.product_uom=pu.id) LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) LEFT JOIN stock_location sl ON (sm.location_id = sl.id) |
def unlink(self, cr, uid, ids, context={}): | def unlink(self, cr, uid, ids, context=None): | def unlink(self, cr, uid, ids, context={}): stor = self.pool.get('document.storage') unres = [] # We have to do the unlink in 2 stages: prepare a list of actual # files to be unlinked, update the db (safer to do first, can be # rolled back) and then unlink the files. The list wouldn't exist # after we discard the objects |
r = stor.prepare_unlink(cr, uid, f.parent_id.storage_id, f) | par = f.parent_id storage_id = None while par: if par.storage_id: storage_id = par.storage_id break par = par.parent_id assert storage_id, "Strange, found file r = stor.prepare_unlink(cr, uid, storage_id, f) | def unlink(self, cr, uid, ids, context={}): stor = self.pool.get('document.storage') unres = [] # We have to do the unlink in 2 stages: prepare a list of actual # files to be unlinked, update the db (safer to do first, can be # rolled back) and then unlink the files. The list wouldn't exist # after we discard the objects |
partner_address_id = val_invoice['value']['address_invoice_id'] value = inv_lines_pool.product_id_change(cr, uid, [], reg.event_id.product_id.id, uom =False, partner_id=reg.partner_invoice_id.id, fposition_id=reg.partner_invoice_id.property_account_position.id) l = inv_lines_pool.read(cr, uid, lines) | def _make_invoice(self, cr, uid, reg, lines, context=None): """ Create Invoice from Invoice lines @param reg : Model of Event Registration @param lines: Ids of Invoice lines """ if context is None: context = {} inv_pool = self.pool.get('account.invoice') inv_lines_pool = self.pool.get('account.invoice.line') |
|
contact_id = contact_obj.browse(cr, uid, contact) | def onchange_contact_id(self, cr, uid, ids, contact, partner): |
|
res.update({'text': '\n\n'+(case.user_id.signature or '') + '\n\n' + (case.description or '')}) | res.update({'text': '\n\n'+(case.user_id.signature or '')}) | def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {} |
nodes = doc.xpath("//page[@name='journal_ids']") | nodes = doc.xpath("//field[@name='journal_ids']") | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): mod_obj = self.pool.get('ir.model.data') res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) doc = etree.XML(res['arch']) nodes = doc.xpath("//page[@name='journal_ids']") for node in nodes: node.set('invisible', '1') res['arch'] = etree.tostring(doc) return res |
node.set('invisible', '1') | node.set('readonly', '1') node.set('required', '0') | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): mod_obj = self.pool.get('ir.model.data') res = super(account_bs_report, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=False) doc = etree.XML(res['arch']) nodes = doc.xpath("//page[@name='journal_ids']") for node in nodes: node.set('invisible', '1') res['arch'] = etree.tostring(doc) return res |
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context) | def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): cr.execute('select distinct parent_id from account_tax_code where id =ANY(%s)',(ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True |
|
except : raise Exception(exceptions.html_error_template().render()) | except Exception, e: raise except_osv(exceptions.html_error_template().render()) | def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) |
raise Exception(exceptions.html_error_template().render()) | raise except_osv(exceptions.html_error_template().render()) | def create_single_pdf(self, cursor, uid, ids, data, report_xml, context=None): """generate the PDF""" if context is None: context={} if report_xml.report_type != 'webkit': return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) |
raise osv.except_osv(_('Warning !'),_('Not Available. Moves are not confirmed.')) | raise osv.except_osv(_('Warning !'),_('Not enough stock, unable to reserve the products.')) | def action_assign(self, cr, uid, ids, *args): """ Changes state of picking to available if all moves are confirmed. @return: True """ for pick in self.browse(cr, uid, ids): move_ids = [x.id for x in pick.move_lines if x.state == 'confirmed'] if not move_ids: raise osv.except_osv(_('Warning !'),_('Not Available. Moves are not confirmed.')) self.pool.get('stock.move').action_assign(cr, uid, move_ids) return True |
'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner"), | 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), | def _search_amount(self, cr, uid, obj, name, args, context): ids = set() for cond in args: amount = cond[2] if isinstance(cond[2],(list,tuple)): if cond[1] in ['in','not in']: amount = tuple(cond[2]) else: continue else: if cond[1] in ['=like', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of']: continue |
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} if context is None: context = {} default = default.copy() default['member_lines'] = [] return super(Partner, self).copy(cr, uid, id, default, context) | def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): cr.execute('select distinct associate_member from res_partner where id =ANY(%s)',(ids,)) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True |
|
copy_val += " or '" + null_value + "'" | copy_val += " or '''%s'''" % null_value | def compute_pl(self, model_object_field, sub_model_object_field, null_value, template_language='mako'): """ Returns the expression based on data provided @param model_object_field: First level field @param sub_model_object_field: Second level drilled down field (M2O) @param null_value: What has to be returned if the value is empty @param template_language: The language used for templating @return: computed expression """ #Configure for MAKO copy_val = '' if template_language == 'mako': if model_object_field: copy_val = "${object." + model_object_field if sub_model_object_field: copy_val += "." + sub_model_object_field if null_value: copy_val += " or '" + null_value + "'" if model_object_field: copy_val += "}" elif template_language == 'django': if model_object_field: copy_val = "{{object." + model_object_field if sub_model_object_field: copy_val += "." + sub_model_object_field if null_value: copy_val = copy_val + '|default:"' + null_value + '"' copy_val = copy_val + "}}" return copy_val |
copy_val = copy_val + '|default:"' + null_value + '"' | copy_val = copy_val + "|default:'''%s'''" % null_value | def compute_pl(self, model_object_field, sub_model_object_field, null_value, template_language='mako'): """ Returns the expression based on data provided @param model_object_field: First level field @param sub_model_object_field: Second level drilled down field (M2O) @param null_value: What has to be returned if the value is empty @param template_language: The language used for templating @return: computed expression """ #Configure for MAKO copy_val = '' if template_language == 'mako': if model_object_field: copy_val = "${object." + model_object_field if sub_model_object_field: copy_val += "." + sub_model_object_field if null_value: copy_val += " or '" + null_value + "'" if model_object_field: copy_val += "}" elif template_language == 'django': if model_object_field: copy_val = "{{object." + model_object_field if sub_model_object_field: copy_val += "." + sub_model_object_field if null_value: copy_val = copy_val + '|default:"' + null_value + '"' copy_val = copy_val + "}}" return copy_val |
fobj.import_cal(cr, uid, base64.encodestring(data), context=ctx) | fobj.import_cal(cr, uid, base64.encodestring(data), context=context) | def process_write(self, cr, uid, node, data, context=None): if node.extension != '.ics': return super(document_directory_content, self).process_write(cr, uid, node, data, context) content = self.browse(cr, uid, node.cnt_id, context) fobj = self.pool.get(content.object_id.model) fobj.import_cal(cr, uid, base64.encodestring(data), context=ctx) |
message = (n +" '" + case.name + "' "+ _("has been closed.") | message = n +" '" + case.name + "' "+ _("has been closed.") | def case_close(self, cr, uid, ids, *args): """Overrides close for crm_case for setting close date @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 *args: Tuple Value for additional Params """ res = super(crm_lead, self).case_close(cr, uid, ids, args) self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) for case in self.browse(cr, uid, ids): n = { 'lead': _('The lead'), 'opportunity': _('The opportunity') }.get(case.type, _('The case')) message = (n +" '" + case.name + "' "+ _("has been closed.") self.log(cr, uid, id, message) return res |
raise except_orm(_('UnknownError'), str(e)) | raise | def create(self, cr, uid, vals, context={}): try: res = super(account_invoice, self).create(cr, uid, vals, context) return res except Exception,e: if '"journal_id" viol' in e.args[0]: raise except_orm(_('Configuration Error!'), _('There is no Accounting Journal of type Sale/Purchase defined!')) else: raise except_orm(_('UnknownError'), str(e)) |
m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) journal_id = m.journal_id.id period_id = m.period_id.id | if vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) journal_id = m.journal_id.id period_id = m.period_id.id | def _check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} journal_id = False if 'date' in vals.keys(): if 'journal_id' in vals and 'journal_id' not in context: journal_id = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: period_id = vals['period_id'] elif 'journal_id' not in context and 'move_id' in vals: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) journal_id = m.journal_id.id period_id = m.period_id.id else: journal_id = context.get('journal_id',False) period_id = context.get('period_id',False) if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date and period_id: period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] if not time.strptime(vals['date'][:10],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'][:10],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Journal Entry is not in the defined period!')) else: return True |
cr.execute(query, (ids,)) | cr.execute(query, (tuple(ids),)) | def _get_answers(cr, uid, ids): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm profiling’s IDs """ query = """ select distinct(answer) from profile_question_yes_rel where profile IN %s""" cr.execute(query, (ids,)) ans_yes = [x[0] for x in cr.fetchall()] query = """ select distinct(answer) from profile_question_no_rel where profile IN %s""" cr.execute(query, (tuple(ids),)) ans_no = [x[0] for x in cr.fetchall()] return [ans_yes, ans_no] |
'name': subject or 'History', | 'name': subject or _('History'), | def history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, email_cc=None, \ email_bcc=None, email_date=None, context=None): """ @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 cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email-To / Recipient address @param email_from: Email From / Sender address if any @param email_cc: Comma-Separated list of Carbon Copy Emails To addresse if any @param email_bcc: Comma-Separated list of Blind Carbon Copy Emails To addresses if any @param email_date: Email Date string if different from now, in server Timezone @param details: Description, Ddtails of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = [] |
msg_txt += (message.email_from or '/') + ' wrote on ' + format_date_tz(message.date, tz) + ':\n\t' | msg_txt += (message.email_from or '/') + _(' wrote on ') + format_date_tz(message.date, tz) + ':\n\t' | def _get_display_text(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} tz = context.get('tz') result = {} for message in self.browse(cr, uid, ids, context=context): msg_txt = '' if message.history: msg_txt += (message.email_from or '/') + ' wrote on ' + format_date_tz(message.date, tz) + ':\n\t' if message.description: msg_txt += '\n\t'.join(message.description.split('\n')[:3]) + '...' else: msg_txt = (message.user_id.name or '/') + ' on ' + format_date_tz(message.date, tz) + ':\n\t' if message.name == 'Opportunity': msg_txt += "Converted to Opportunity" else: msg_txt += "Changed Status to: " + message.name result[message.id] = msg_txt return result |
msg_txt = (message.user_id.name or '/') + ' on ' + format_date_tz(message.date, tz) + ':\n\t' if message.name == 'Opportunity': msg_txt += "Converted to Opportunity" | msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t' if message.name == _('Opportunity'): msg_txt += _("Converted to Opportunity") | def _get_display_text(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} tz = context.get('tz') result = {} for message in self.browse(cr, uid, ids, context=context): msg_txt = '' if message.history: msg_txt += (message.email_from or '/') + ' wrote on ' + format_date_tz(message.date, tz) + ':\n\t' if message.description: msg_txt += '\n\t'.join(message.description.split('\n')[:3]) + '...' else: msg_txt = (message.user_id.name or '/') + ' on ' + format_date_tz(message.date, tz) + ':\n\t' if message.name == 'Opportunity': msg_txt += "Converted to Opportunity" else: msg_txt += "Changed Status to: " + message.name result[message.id] = msg_txt return result |
msg_txt += "Changed Status to: " + message.name | msg_txt += _("Changed Status to: ") + message.name | def _get_display_text(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} tz = context.get('tz') result = {} for message in self.browse(cr, uid, ids, context=context): msg_txt = '' if message.history: msg_txt += (message.email_from or '/') + ' wrote on ' + format_date_tz(message.date, tz) + ':\n\t' if message.description: msg_txt += '\n\t'.join(message.description.split('\n')[:3]) + '...' else: msg_txt = (message.user_id.name or '/') + ' on ' + format_date_tz(message.date, tz) + ':\n\t' if message.name == 'Opportunity': msg_txt += "Converted to Opportunity" else: msg_txt += "Changed Status to: " + message.name result[message.id] = msg_txt return result |
'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expanse', 'Expanse'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, | 'type': fields.selection([('sale', 'Sale'), ('purchase', 'Purchase'), ('expense', 'Expense'), ('cash', 'Cash'), ('bank', 'Bank'), ('general', 'General'), ('situation', 'Situation')], 'Type', size=32, required=True, | def _col_get(self, cr, user, context={}): result = [] cols = self.pool.get('account.move.line')._columns for col in cols: result.append( (col, cols[col].string) ) result.sort() return result |
'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', type='float', digits=(16, int(config['price_accuracy']))), 'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits=(16, int(config['price_accuracy']))), 'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits=(16, int(config['price_accuracy']))), 'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits=(16, int(config['price_accuracy']))), | 'grows': fields.function(_calculate, method=True, store=True, multi='dc', string='Gross Salary', type='float', digits=(16, 4))), 'net': fields.function(_calculate, method=True, store=True, multi='dc', string='Net Salary', digits=(16, 4)), 'allounce': fields.function(_calculate, method=True, store=True, multi='dc', string='Allowance', digits=(16, 4)), 'deduction': fields.function(_calculate, method=True, store=True, multi='dc', string='Deduction', digits=(16, 4)), | def _calculate(self, cr, uid, ids, field_names, arg, context): res = {} allounce = 0.0 deduction = 0.0 net = 0.0 grows = 0.0 for register in self.browse(cr, uid, ids, context): for slip in register.line_ids: allounce += slip.allounce deduction += slip.deduction net += slip.net grows += slip.grows |
'amount': fields.float('Amount', digits=(16, int(config['price_accuracy']))), 'bysal': fields.float('By Salary', digits=(16, int(config['price_accuracy']))), | 'amount': fields.float('Amount', digits=(16, 4)), 'bysal': fields.float('By Salary', digits=(16, 4)), | def cancel_sheet(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'cancel'}) return True |
'yearly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, int(config['price_accuracy']))), 'yearly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, int(config['price_accuracy']))), 'monthly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, int(config['price_accuracy']))), 'monthly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, int(config['price_accuracy']))), | 'yearly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, 4)), 'yearly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, 4)), 'monthly_total_by_emp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Employee', digits=(16, 4)), 'monthly_total_by_comp': fields.function(_total_contrib, method=True, multi='dc', store=True, string='Total By Company', digits=(16, 4)), | def _total_contrib(self, cr, uid, ids, field_names, arg, context={}): line_pool = self.pool.get('hr.contibution.register.line') period_id = self.pool.get('account.period').search(cr,uid,[('date_start','<=',time.strftime('%Y-%m-%d')),('date_stop','>=',time.strftime('%Y-%m-%d'))])[0] fiscalyear_id = self.pool.get('account.period').browse(cr, uid, period_id).fiscalyear_id res = {} for cur in self.browse(cr, uid, ids): current = line_pool.search(cr, uid, [('period_id','=',period_id),('register_id','=',cur.id)]) years = line_pool.search(cr, uid, [('period_id.fiscalyear_id','=',fiscalyear_id.id), ('register_id','=',cur.id)]) |
'emp_deduction': fields.float('Employee Deduction', digits=(16, int(config['price_accuracy']))), 'comp_deduction': fields.float('Company Deduction', digits=(16, int(config['price_accuracy']))), 'total': fields.function(_total, method=True, store=True, string='Total', digits=(16, int(config['price_accuracy']))), | 'emp_deduction': fields.float('Employee Deduction', digits=(16, 4)), 'comp_deduction': fields.float('Company Deduction', digits=(16, 4)), 'total': fields.function(_total, method=True, store=True, string='Total', digits=(16, 4)), | def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res |
'contribute_per':fields.float('Contribution', digits=(16, int(config['price_accuracy'])), help='Define Company contribution ratio 1.00=100% contribution, If Employee Contribute 5% then company will and here 0.50 defined then company will contribute 50% on employee 5% contribution'), | 'contribute_per':fields.float('Contribution', digits=(16, 4), help='Define Company contribution ratio 1.00=100% contribution, If Employee Contribute 5% then company will and here 0.50 defined then company will contribute 50% on employee 5% contribution'), | def _total(self, cr, uid, ids, field_names, arg, context): res={} for line in self.browse(cr, uid, ids, context): res[line.id] = line.emp_deduction + line.comp_deduction return res |
'from_val': fields.float('From', digits=(16, int(config['price_accuracy']))), 'to_val': fields.float('To', digits=(16, int(config['price_accuracy']))), | 'from_val': fields.float('From', digits=(16, 4)), 'to_val': fields.float('To', digits=(16, 4)), | def execute_function(self, cr, uid, id, value, context): """ self: pointer to self object cr: cursor to database uid: user id of current executer """ |
'value': fields.float('Value', digits=(16, int(config['price_accuracy']))), | 'value': fields.float('Value', digits=(16, 4)), | def execute_function(self, cr, uid, id, value, context): """ self: pointer to self object cr: cursor to database uid: user id of current executer """ |
'total': fields.float('Sub Total', readonly=True, digits=(16, int(config['price_accuracy']))), | 'total': fields.float('Sub Total', readonly=True, digits=(16, 4)), | def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}} |
'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, int(config['price_accuracy']))), | 'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, 4)), | def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}} |
'from_val': fields.float('From', digits=(16, int(config['price_accuracy']))), 'to_val': fields.float('To', digits=(16, int(config['price_accuracy']))), | 'from_val': fields.float('From', digits=(16, 4)), 'to_val': fields.float('To', digits=(16, 4)), | def execute_function(self, cr, uid, id, value, context): line_pool = self.pool.get('hr.payslip.line.line') res = 0 ids = line_pool.search(cr, uid, [('slipline_id','=',id), ('from_val','<=',value), ('to_val','>=',value)]) |
'value': fields.float('Value', digits=(16, int(config['price_accuracy']))), | 'value': fields.float('Value', digits=(16, 4)), | def execute_function(self, cr, uid, id, value, context): line_pool = self.pool.get('hr.payslip.line.line') res = 0 ids = line_pool.search(cr, uid, [('slipline_id','=',id), ('from_val','<=',value), ('to_val','>=',value)]) |
'amount_original': fields.function(_compute_balance, method=True, multi='dc', type='float', string='Originial Amount', store=True), | 'amount_original': fields.function(_compute_balance, method=True, multi='dc', type='float', string='Original Amount', store=True), | def _compute_balance(self, cr, uid, ids, name, args, context=None): currency_pool = self.pool.get('res.currency') rs_data = {} for line in self.browse(cr, uid, ids, context=context): res = {} company_currency = line.voucher_id.journal_id.company_id.currency_id.id voucher_currency = line.voucher_id.currency_id.id move_line = line.move_line_id or False |
message = _("The lead '%s' has been opened.") % name | message = _("The lead '%s' has been opened.") % case.name | def case_open(self, cr, uid, ids, *args): """Overrides cancel for crm_case for setting Open Date @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's Ids @param *args: Give Tuple Value """ old_state = self.read(cr, uid, ids, ['state'])[0]['state'] old_stage_id = self.read(cr, uid, ids, ['stage_id'])[0]['stage_id'] res = super(crm_lead, self).case_open(cr, uid, ids, *args) if old_state == 'draft': value = {} if not old_stage_id: stage_id = super(crm_lead, self).stage_next(cr, uid, ids, *args) if stage_id: value.update({'stage_id': stage_id}) value.update(self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']) value.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, ids, value) |
message = _("The opportunity '%s' has been opened.") % name | message = _("The opportunity '%s' has been opened.") % case.name | def case_open(self, cr, uid, ids, *args): """Overrides cancel for crm_case for setting Open Date @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's Ids @param *args: Give Tuple Value """ old_state = self.read(cr, uid, ids, ['state'])[0]['state'] old_stage_id = self.read(cr, uid, ids, ['stage_id'])[0]['stage_id'] res = super(crm_lead, self).case_open(cr, uid, ids, *args) if old_state == 'draft': value = {} if not old_stage_id: stage_id = super(crm_lead, self).stage_next(cr, uid, ids, *args) if stage_id: value.update({'stage_id': stage_id}) value.update(self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']) value.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, ids, value) |
message = _("The case '%s' has been opened.") % name | message = _("The case '%s' has been opened.") % case.name | def case_open(self, cr, uid, ids, *args): """Overrides cancel for crm_case for setting Open Date @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's Ids @param *args: Give Tuple Value """ old_state = self.read(cr, uid, ids, ['state'])[0]['state'] old_stage_id = self.read(cr, uid, ids, ['stage_id'])[0]['stage_id'] res = super(crm_lead, self).case_open(cr, uid, ids, *args) if old_state == 'draft': value = {} if not old_stage_id: stage_id = super(crm_lead, self).stage_next(cr, uid, ids, *args) if stage_id: value.update({'stage_id': stage_id}) value.update(self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']) value.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, ids, value) |
message = _("The lead '%s' has been closed.") % name | message = _("The lead '%s' has been closed.") % case.name | def case_close(self, cr, uid, ids, *args): """Overrides close for crm_case for setting close date @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 *args: Tuple Value for additional Params """ res = super(crm_lead, self).case_close(cr, uid, ids, args) self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) for case in self.browse(cr, uid, ids): if case.type == 'lead': message = _("The lead '%s' has been closed.") % name elif case.type == 'opportunity': message = _("The opportunity '%s' has been closed.") % name else: message = _("The case '%s' has been closed.") % name self.log(cr, uid, case.id, message) return res |
message = _("The opportunity '%s' has been closed.") % name | message = _("The opportunity '%s' has been closed.") % case.name | def case_close(self, cr, uid, ids, *args): """Overrides close for crm_case for setting close date @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 *args: Tuple Value for additional Params """ res = super(crm_lead, self).case_close(cr, uid, ids, args) self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) for case in self.browse(cr, uid, ids): if case.type == 'lead': message = _("The lead '%s' has been closed.") % name elif case.type == 'opportunity': message = _("The opportunity '%s' has been closed.") % name else: message = _("The case '%s' has been closed.") % name self.log(cr, uid, case.id, message) return res |
message = _("The case '%s' has been closed.") % name | message = _("The case '%s' has been closed.") % case.name | def case_close(self, cr, uid, ids, *args): """Overrides close for crm_case for setting close date @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 *args: Tuple Value for additional Params """ res = super(crm_lead, self).case_close(cr, uid, ids, args) self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')}) for case in self.browse(cr, uid, ids): if case.type == 'lead': message = _("The lead '%s' has been closed.") % name elif case.type == 'opportunity': message = _("The opportunity '%s' has been closed.") % name else: message = _("The case '%s' has been closed.") % name self.log(cr, uid, case.id, message) return res |
'type':fields.selection([ | 'server_type':fields.selection([ | def fetch_mail(self, cr, uid, ids, context=None): if not context: context = {} email_tool = self.pool.get('email.server.tools') for server in self.browse(cr, uid, ids, context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 try: if server.type == 'imap': imap_server = None if server.is_ssl: imap_server = IMAP4_SSL(server.server, int(server.port)) else: imap_server = IMAP4(server.server, int(server.port)) |
res[hist.id] = (hist.email or '/') + ' (' + str(hist.date) + ')\n' | res[hist.id] = (hist.email_from or '/') + ' (' + str(hist.date) + ')\n' | def _note_get(self, cursor, user, ids, name, arg, context=None): """ Gives case History Description @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 History’s IDs @param context: A standard dictionary for contextual values """ res = {} for hist in self.browse(cursor, user, ids, context or {}): res[hist.id] = (hist.email or '/') + ' (' + str(hist.date) + ')\n' res[hist.id] += (hist.description or '') return res |
"""Sets duration as 24 Hours if event is selcted for all day | """Sets duration as 24 Hours if event is selected for all day | def onchange_allday(self, cr, uid, ids, allday, context=None): """Sets duration as 24 Hours if event is selcted for all day @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 calendar event’s IDs. @param allday: Value of allday boolean @param context: A standard dictionary for contextual values """ if not allday or not ids: return {} event = self.browse(cr, uid, ids, context=context)[0] value = { 'duration': 24 } return {'value': value} |
def _balance(self, cr, uid, ids, prop, unknow_none, unknow_dict): res={} for id in ids: cr.execute('SELECT date,account_id FROM account_move_line WHERE id=%s', (id,)) dt, acc = cr.fetchone() cr.execute('SELECT SUM(debit-credit) FROM account_move_line WHERE account_id=%s AND (date<%s OR (date=%s AND id<=%s))', (acc,dt,dt,id)) res[id] = cr.fetchone()[0] | def _balance(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} c = context.copy() c['initital_bal'] = True sql = [ """select l2.id, sum(l1.debit-l1.credit) from account_move_line l1, account_move_line l2""", """where l2.account_id=l1.account_id""", """and""", """l1.id<=l2.id""", """and""", """l2.id in %s""", """and""", self._query_get(cr, uid, obj='l1', context=c), """ group by l2.id""", ] cr.execute('\n'.join(sql), [tuple(ids)]) res = dict(cr.fetchall()) | def on_create_write(self, cr, uid, id, context={}): ml = self.browse(cr, uid, id, context) return map(lambda x: x.id, ml.move_id.line_id) |
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer'), | 'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', store=True, string='Customer'), | def _number_packages(self, cr, uid, ids, field_name, arg, context=None): if context is None: context = {} 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': "{'visible_id':%s, 'journal_id': %d, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (journal_id, journal_id, journal_id, period_id), | 'context': "{'visible_id':%s, 'search_default_journal_id':%d, 'search_default_period_id':%d}" % (journal_id, journal_id, period_id), | def action_open_window(self, cr, uid, ids, context=None): """ This function Open action move line window on given period and Journal/Payment Mode @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: account move journal’s ID or list of IDs @return: dictionary of Open action move line window on given period and Journal/Payment Mode """ period_pool = self.pool.get('account.journal.period') data_pool = self.pool.get('ir.model.data') journal_pool = self.pool.get('account.journal') if context is None: context = {} journal_id = self._get_journal(cr, uid, context) period_id = self._get_period(cr, uid, context) |
account_jrnl_obj=self.pool.get('account.journal') | def makeInvoices(self, cr, uid, ids, context=None): """ To get Purchase Order line and create Invoice @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : retrun view of Invoice """ if context is None: context={} record_ids = context.get('active_ids',[]) if record_ids: res = False invoices = {} invoice_obj=self.pool.get('account.invoice') purchase_line_obj=self.pool.get('purchase.order.line') property_obj=self.pool.get('ir.property') account_fiscal_obj=self.pool.get('account.fiscal.position') invoice_line_obj=self.pool.get('account.invoice.line') def multiple_order_invoice_name(orders): name = "PO"; for order in orders: name += "-%d" % order.id return name def multiple_order_invoice_reference(partner, orders): reference = "P%dPO" % partner.id for order in orders: reference += "-%d" % order.id return reference def multiple_order_invoice_notes(orders): notes = "" for order in orders: notes += "%s \n" % order.notes return notes def make_invoice_by_partner(partner, orders, lines_ids): """ create a new invoice for one supplier @param partner : The object partner @param orders : The set of orders to add in the invoice @param lines : The list of line's id """ a = partner.property_account_payable.id if partner and partner.property_payment_term.id: pay_term = partner.property_payment_term.id else: pay_term = False inv = { 'name': multiple_order_invoice_name(orders), 'origin': multiple_order_invoice_name(orders), 'type': 'in_invoice', 'reference': multiple_order_invoice_reference(partner, orders), 'account_id': a, 'partner_id': partner.id, 'address_invoice_id': orders[0].partner_address_id.id, 'address_contact_id': orders[0].partner_address_id.id, 'invoice_line': [(6,0,lines_ids)], 'currency_id' : orders[0].pricelist_id.currency_id.id, 'comment': multiple_order_invoice_notes(orders), 'payment_term': pay_term, 'fiscal_position': partner.property_account_position.id } inv_id = invoice_obj.create(cr, uid, inv) return inv_id |
|
journal_id_get = account_jrnl_obj.search(cr,uid,[('type','=','purchase')],context=None)[0] | def make_invoice_by_partner(partner, orders, lines_ids): """ create a new invoice for one supplier @param partner : The object partner @param orders : The set of orders to add in the invoice @param lines : The list of line's id """ a = partner.property_account_payable.id if partner and partner.property_payment_term.id: pay_term = partner.property_payment_term.id else: pay_term = False inv = { 'name': multiple_order_invoice_name(orders), 'origin': multiple_order_invoice_name(orders), 'type': 'in_invoice', 'reference': multiple_order_invoice_reference(partner, orders), 'account_id': a, 'partner_id': partner.id, 'address_invoice_id': orders[0].partner_address_id.id, 'address_contact_id': orders[0].partner_address_id.id, 'invoice_line': [(6,0,lines_ids)], 'currency_id' : orders[0].pricelist_id.currency_id.id, 'comment': multiple_order_invoice_notes(orders), 'payment_term': pay_term, 'fiscal_position': partner.property_account_position.id } inv_id = invoice_obj.create(cr, uid, inv) return inv_id |
|
'date':inv.date, 'ref':inv.reference, | 'date': inv.date, 'ref': ref, | def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False |
_description = 'Production' | _description = 'Manufacturing Order' | def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None): if not context: context = {} res = {} move_obj = obj.pool.get('stock.move') for prod in obj.browse(cr, user, ids, context=context): cr.execute("SELECT id from stock_move where production_id=%s" % (prod.id)) m_ids = map(lambda x: x[0], cr.fetchall()) final = move_obj.search(cr, user, self._domain + [('id', 'in', tuple(m_ids))]) res[prod.id] = final return res |
'sale_id': picking.sale_id.id | 'sale_id':' sale_id' in picking._columns.keys() and picking.sale_id.id or False | def create_chained_picking(self, cr, uid, moves, context=None): new_moves = [] res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') if context is None: context = {} for picking, todo in self._chain_compute(cr, uid, moves, context=context).items(): ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0]) pick_name = picking.name if ptype == 'delivery': pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery') |
'product_uom': lambda self,cr,uid,c: self.pool.get('product.uom').search(cr, uid, [('name', '=', 'Day')], context=c)[0] | 'product_uom': lambda self,cr,uid,c: self.pool.get('product.uom').search(cr, uid, [('name', '=', 'day')], context=c)[0] | def _get_default_uom_id(self, cr, uid): model_data_obj = self.pool.get('ir.model.data') model_data_id = model_data_obj._get_id(cr, uid, 'product', 'uom_hour') return model_data_obj.read(cr, uid, [model_data_id], ['res_id'])[0]['res_id'] |
res['arch'] = res['arch'].replace('</search>',search_extended) | res['arch'] = unicode(res['arch'], 'utf8').replace('</search>', search_extended) | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): res = super(project_task,self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) search_extended = False timebox_obj = self.pool.get('project.gtd.timebox') access_pool = self.pool.get('ir.model.access') if (res['type'] == 'search') and access_pool.check_groups(cr, uid, "project_gtd.group_project_getting"): tt = timebox_obj.browse(cr, uid, timebox_obj.search(cr,uid,[])) search_extended ='''<newline/><group col="%d" expand="%d" string="%s">''' % (len(tt)+7,1,_('Getting Things Done')) search_extended += '''<filter domain="[('timebox_id','=', False)]" context="{'set_editable':True,'set_visible':True,'gtd_visible':True,'user_invisible':True}" icon="gtk-new" help="Undefined Timebox" string="%s"/>''' % (_('Inbox'),) search_extended += '''<filter context="{'set_editable':True,'set_visible':True,'gtd_visible':True,'user_invisible':True}" icon="gtk-new" string="%s"/>''' % (_('GTD'),) search_extended += '''<separator orientation="vertical"/>''' for time in tt: if time.icon: icon = time.icon else : icon="" search_extended += '''<filter domain="[('timebox_id','=', ''' + str(time.id) + ''')]" icon="''' + icon + '''" string="''' + time.name + '''" context="{'gtd_visible':True, 'user_invisible': True}"/>''' search_extended += ''' <separator orientation="vertical"/> <field name="context_id" select="1" widget="selection"/> </group> </search> ''' if search_extended: res['arch'] = res['arch'].replace('</search>',search_extended) attrs_sel = self.pool.get('project.gtd.context').name_search(cr, uid, '', [], context=context) context_id_info = self.pool.get('project.task').fields_get(cr, uid, ['context_id']) context_id_info['context_id']['selection'] = attrs_sel res['fields'].update(context_id_info) return res |
function_id = self.pool.get('res.partner.function').search(cr,uid,[('name','=',lead.function_name)]) | def _create_partner(self, cr, uid, ids, context=None): """ This function Creates partner based on action. @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 Lead to Partner's IDs @param context: A standard dictionary for contextual values |
|
'function': function_id and function_id[0] or False, | 'function': lead.function_name, | def _create_partner(self, cr, uid, ids, context=None): """ This function Creates partner based on action. @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 Lead to Partner's IDs @param context: A standard dictionary for contextual values |
if check and not context.get('no_store_function'): | if check and ((not context.get('no_store_function')) or journal.entry_posted): | def create(self, cr, uid, vals, context=None, check=True): if not context: context={} account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals and 'journal_id' not in context: context['journal_id'] = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = self.pool.get('account.move').browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id |
dedicated_salesman = part.user_id and part.user_id.id or False | dedicated_salesman = part.user_id and part.user_id.id or uid | def onchange_partner_id(self, cr, uid, ids, part): if not part: return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}} |
def split_to_ids(self, ids_as_str): """ Identifies email IDs separated by separators and returns a list TODO: Doc this "a@b.com,c@bcom; d@b.com;e@b.com->['a@b.com',...]" """ email_sep_by_commas = ids_as_str \ .replace('; ', ',') \ .replace(';', ',') \ .replace(', ', ',') return email_sep_by_commas.split(',') def get_ids_from_dict(self, addresses={}): """ TODO: Doc this """ result = {'all':[]} keys = ['To', 'CC', 'BCC', 'Reply-To'] for each in keys: ids_as_list = self.split_to_ids(addresses.get(each, u'')) while u'' in ids_as_list: ids_as_list.remove(u'') result[each] = ids_as_list result['all'].extend(ids_as_list) return result | def split_to_ids(self, ids_as_str): """ Identifies email IDs separated by separators and returns a list TODO: Doc this "a@b.com,c@bcom; d@b.com;e@b.com->['a@b.com',...]" """ email_sep_by_commas = ids_as_str \ .replace('; ', ',') \ .replace(';', ',') \ .replace(', ', ',') return email_sep_by_commas.split(',') |
|
addresses_l = self.get_ids_from_dict(addresses) | addresses_l = extract_emails_from_dict(addresses) | def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None): #TODO: Replace all this with a single email object if body is None: body = {} if payload is None: payload = {} if context is None: context = {} logger = netsvc.Logger() for id in ids: core_obj = self.browse(cr, uid, id, context) serv = self.smtp_connection(cr, uid, id) if serv: try: # Prepare multipart containers depending on data text_subtype = (core_obj.send_pref == 'alternative') and 'alternative' or 'mixed' # Need a multipart/mixed wrapper for attachments if content is alternative if payload and text_subtype == 'alternative': payload_part = MIMEMultipart(_subtype='mixed') text_part = MIMEMultipart(_subtype=text_subtype) payload_part.attach(text_part) else: # otherwise a single multipart/mixed will do the whole job payload_part = text_part = MIMEMultipart(_subtype=text_subtype) |
serv.sendmail(payload_part['From'], addresses_l['all'], payload_part.as_string()) | serv.sendmail(payload_part['From'], addresses_l['all-recipients'], payload_part.as_string()) | def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None): #TODO: Replace all this with a single email object if body is None: body = {} if payload is None: payload = {} if context is None: context = {} logger = netsvc.Logger() for id in ids: core_obj = self.browse(cr, uid, id, context) serv = self.smtp_connection(cr, uid, id) if serv: try: # Prepare multipart containers depending on data text_subtype = (core_obj.send_pref == 'alternative') and 'alternative' or 'mixed' # Need a multipart/mixed wrapper for attachments if content is alternative if payload and text_subtype == 'alternative': payload_part = MIMEMultipart(_subtype='mixed') text_part = MIMEMultipart(_subtype=text_subtype) payload_part.attach(text_part) else: # otherwise a single multipart/mixed will do the whole job payload_part = text_part = MIMEMultipart(_subtype=text_subtype) |
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Server Send Error\nDescription: %s") % (id, error)) | logging.getLogger('email_template').error("Mail from Account %s failed. Probable Reason: Server Send Error\n Description: %s", id, error, exc_info=True) | def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None): #TODO: Replace all this with a single email object if body is None: body = {} if payload is None: payload = {} if context is None: context = {} logger = netsvc.Logger() for id in ids: core_obj = self.browse(cr, uid, id, context) serv = self.smtp_connection(cr, uid, id) if serv: try: # Prepare multipart containers depending on data text_subtype = (core_obj.send_pref == 'alternative') and 'alternative' or 'mixed' # Need a multipart/mixed wrapper for attachments if content is alternative if payload and text_subtype == 'alternative': payload_part = MIMEMultipart(_subtype='mixed') text_part = MIMEMultipart(_subtype=text_subtype) payload_part.attach(text_part) else: # otherwise a single multipart/mixed will do the whole job payload_part = text_part = MIMEMultipart(_subtype=text_subtype) |
return super(report_creator, self).read(cr, user, ids, fields, context, load) | return res | def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): """ overrides orm Read method.Read List of fields for report creator. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @param ids: List of report creator's id. @param fields: List of fields. @return: List of Dictionary of form [{‘name_of_the_field’: value, ...}, ...] """ if context is None: context = {} data = context.get('report_id', False) if (not context) or 'report_id' not in context: return super(report_creator, self).read(cr, user, ids, fields, context, load) ctx = context or {} wp = '' if data: if self.model_set_id: wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))] report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) sql_query = report[data] cr.execute(sql_query) res = cr.dictfetchall() fields_get = self.fields_get(cr, user, None, context) for r in res: for k in r: r[k] = r[k] or False field_dict = fields_get.get(k) field_type = field_dict and field_dict.get('type', False) or False if field_type and field_type == 'many2one': if r[k] == False: continue related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0] r[k] = related_name |
if data: | for data in res: if not data.get('sql_query'): return res | def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): """ overrides orm Read method.Read List of fields for report creator. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @param ids: List of report creator's id. @param fields: List of fields. @return: List of Dictionary of form [{‘name_of_the_field’: value, ...}, ...] """ if context is None: context = {} data = context.get('report_id', False) if (not context) or 'report_id' not in context: return super(report_creator, self).read(cr, user, ids, fields, context, load) ctx = context or {} wp = '' if data: if self.model_set_id: wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))] report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) sql_query = report[data] cr.execute(sql_query) res = cr.dictfetchall() fields_get = self.fields_get(cr, user, None, context) for r in res: for k in r: r[k] = r[k] or False field_dict = fields_get.get(k) field_type = field_dict and field_dict.get('type', False) or False if field_type and field_type == 'many2one': if r[k] == False: continue related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0] r[k] = related_name |
report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) sql_query = report[data] cr.execute(sql_query) | cr.execute(data['sql_query']) | def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'): """ overrides orm Read method.Read List of fields for report creator. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @param ids: List of report creator's id. @param fields: List of fields. @return: List of Dictionary of form [{‘name_of_the_field’: value, ...}, ...] """ if context is None: context = {} data = context.get('report_id', False) if (not context) or 'report_id' not in context: return super(report_creator, self).read(cr, user, ids, fields, context, load) ctx = context or {} wp = '' if data: if self.model_set_id: wp = [self._id_get(cr, user, data, context) + (' in (%s)' % (','.join(map(lambda x: "'" + str(x) + "'", ids))))] report = self._sql_query_get(cr, user, [data], 'sql_query', None, ctx, where_plus = wp) sql_query = report[data] cr.execute(sql_query) res = cr.dictfetchall() fields_get = self.fields_get(cr, user, None, context) for r in res: for k in r: r[k] = r[k] or False field_dict = fields_get.get(k) field_type = field_dict and field_dict.get('type', False) or False if field_type and field_type == 'many2one': if r[k] == False: continue related_name = self.pool.get(field_dict.get('relation')).name_get(cr, user, [r[k]], context)[0] r[k] = related_name |
report = self._sql_query_get(cr, user, [context_id], 'sql_query', None, ctx, where_plus = newargs, limit=limit, offset=offset) query = report[context_id] cr.execute(query, newargs2) | sql_query = report.sql_query cr.execute(sql_query, newargs2) | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ overrides orm search method. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @return: List of id """ if context is None: context = {} context_id = context.get('report_id', False) |
if prodlot_id: self.write(cr, uid, [move.id],{'prodlot_id': prodlot_id,}) | def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial pickings and moves done. @param partial_datas: Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom """ res = {} picking_obj = self.pool.get('stock.picking') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) new_moves = [] |
|
id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet') id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet') id4 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet') if id2: id2 = data_obj.browse(cr, uid, id2, context=context).res_id if id3: id3 = data_obj.browse(cr, uid, id3, context=context).res_id if id4: id4 = data_obj.browse(cr, uid, id4, context=context).res_id for id in ids: value = { 'name': _('Meeting'), 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'crm.meeting', 'view_id': False, 'views': [(id2, 'form'), (id3, 'tree'), (id4, 'calendar')], 'type': 'ir.actions.act_window', 'res_id': base_calendar.base_calendar_id2real_id(id), 'nodestroy': True } | if edit_all and rrule_type: for id in ids: base_calendar.base_calendar_id2real_id(id) | def open_meeting(self, cr, uid, ids, context=None): """ Open Crm Meeting Form for Crm Meeting. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of crm meeting’s IDs @param context: A standard dictionary for contextual values @return: Dictionary value which open Crm Meeting form. """ |
def _get_number_of_days(date_from, date_to): | def _get_number_of_days(self, date_from, date_to): | def _get_number_of_days(date_from, date_to): """Returns a float equals to the timedelta between two dates given as string.""" |
diff_day = timedelta.days + float(timedelata.seconds) / 86400 | diff_day = timedelta.days + float(timedelta.seconds) / 86400 | def _get_number_of_days(date_from, date_to): """Returns a float equals to the timedelta between two dates given as string.""" |
return onchange_date_from(cr, uid, ids, date_to, date_from) | return self.onchange_date_from(cr, uid, ids, date_to, date_from) | def onchange_date_to(self, cr, uid, ids, date_from, date_to): return onchange_date_from(cr, uid, ids, date_to, date_from) |
message = (n +" '" + case.name + "' "+ _("has been opened.") | message = n +" '" + case.name + "' "+ _("has been opened.") | def case_open(self, cr, uid, ids, *args): """Overrides cancel for crm_case for setting Open Date @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's Ids @param *args: Give Tuple Value """ old_state = self.read(cr, uid, ids, ['state'])[0]['state'] old_stage_id = self.read(cr, uid, ids, ['stage_id'])[0]['stage_id'] res = super(crm_lead, self).case_open(cr, uid, ids, *args) if old_state == 'draft': value = {} if not old_stage_id: stage_id = super(crm_lead, self).stage_next(cr, uid, ids, *args) if stage_id: value.update({'stage_id': stage_id}) value.update(self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']) value.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) self.write(cr, uid, ids, value) |
cr = self.get_node_cr(node) | def rmdir(self, datacr): """Remove the specified directory.""" cr, node, rem = datacr assert node cr = self.get_node_cr(node) node.rmcol(cr) cr.commit() |
|
self.do_alarm_unlink(cr, uid, ids) | alarm_obj = self.pool.get('res.alarm') alarm_obj.do_alarm_unlink(cr, uid, ids, self._name) | def unlink(self, cr, uid, ids, context=None): res = False for id in ids: ls = common.caldav_id2real_id(id) if not isinstance(ls, (str, int, long)) and len(ls) >= 2: date_new = ls[1] for record in self.read(cr, uid, [common.caldav_id2real_id(id)], \ ['date', 'rrule', 'exdate']): if record['rrule']: exdate = (record['exdate'] and (record['exdate'] + ',') or '') + \ ''.join((re.compile('\d')).findall(date_new)) + 'Z' if record['date'] == date_new: res = self.write(cr, uid, [common.caldav_id2real_id(id)], {'exdate': exdate}) else: ids = map(lambda x: common.caldav_id2real_id(x), ids) res = super(crm_meeting, self).unlink(cr, uid, common.caldav_id2real_id(ids)) self.do_alarm_unlink(cr, uid, ids) else: ids = map(lambda x: common.caldav_id2real_id(x), ids) res = super(crm_meeting, self).unlink(cr, uid, ids) self.do_alarm_unlink(cr, uid, ids) return res |
p = prod_obj.browse(cr, uid, s[0]) invent_line_obj.create(cr, uid, { | p = product_obj.browse(cr, uid, s[0]) inventory_line_obj.create(cr, uid, { | def fill_inventory(self, cr, uid, ids, context): """ To Import stock inventory according to products available in the selected locations. @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 if we want more than one @param context: A standard dictionary @return: """ inventory_line_obj = self.pool.get('stock.inventory.line') location_obj = self.pool.get('stock.location') product_obj = self.pool.get('product.product') stock_location_obj = self.pool.get('stock.location') for fill_inventory in self.browse(cr, uid, ids): res = {} res_location = {} if fill_inventory.recursive : location_ids = location_obj.search(cr, uid, [('location_id', 'child_of', fill_inventory.location_id.id)]) for location in location_ids : res = location_obj._product_get(cr, uid, location) res_location[location] = res if fill_inventory.set_stock_zero: loc = fill_inventory.location_id.id cr.execute('select distinct location_id,product_id \ from stock_inventory_line \ where inventory_id=%s', (context['active_id'],)) inv = cr.fetchall() cr.execute('select distinct product_id from stock_move where \ location_dest_id=%s or location_id=%s', (loc, loc,)) stock = cr.fetchall() for s in stock: if (loc, s[0]) not in inv: p = prod_obj.browse(cr, uid, s[0]) invent_line_obj.create(cr, uid, { 'inventory_id': context['active_id'], 'location_id': loc, 'product_id': s[0], 'product_uom': p.uom_id.id, 'product_qty': 0.0, }) else: context.update({'compute_child': False}) res = location_obj._product_get(cr, uid, fill_inventory.location_id.id, context=context) res_location[fill_inventory.location_id.id] = res product_ids = [] for location in res_location.keys(): res = res_location[location] for product_id in res.keys(): prod = product_obj.browse(cr, uid, [product_id])[0] uom = prod.uom_id.id context.update(uom=uom, compute_child=False) amount = stock_location_obj._product_get(cr, uid, location, [product_id], context=context)[product_id] |
data['ids']=data['form']['chart_account_id'] | data['ids'] = [data['form']['chart_account_id']] | def _print_report(self, cr, uid, ids, data, query_line, context=None): |
message = str(production_qty) + " '[" + production.product_id.code + '] ' + production.product_id.name + _("' have been manufactured for ") + production.name | for (id, name) in self.pool.get('product.product').name_get(cr, uid, [production.product_id.id]): message = str(production_qty) + ' ' + production.product_uom.name +" '" + name + _("' have been manufactured for ") + production.name | def action_produce(self, cr, uid, production_id, production_qty, production_mode, context=None): """ To produce final product base on production mode (consume/consume&produce). If Production mode is consume, all stock move lines of raw materials will be done/consumed. If Production mode is consume & produce, all stock move lines of raw materials will be done/consumed and stock move lines of final product will be also done/produced. @param production_id: the ID of mrp.production object @param production_qty: specify qty to produce @param production_mode: specify production mode (consume/consume&produce). @return: True """ stock_mov_obj = self.pool.get('stock.move') production = self.browse(cr, uid, production_id) raw_product_todo = [] final_product_todo = [] |
drop_view_if_exists(cr, 'stock_report_prodlots') | drop_view_if_exists(cr, 'stock_report_tracklots') | def init(self, cr): drop_view_if_exists(cr, 'stock_report_prodlots') cr.execute(""" create or replace view stock_report_tracklots as ( select max(id) as id, location_id, product_id, tracking_id, sum(qty) as name from ( select -max(sm.id) as id, sm.location_id, sm.product_id, sm.tracking_id, -sum(sm.product_qty /uo.factor) as qty from stock_move as sm left join stock_location sl on (sl.id = sm.location_id) left join product_uom uo on (uo.id=sm.product_uom) where state = 'done' group by sm.location_id, sm.product_id, sm.product_uom, sm.tracking_id union all select max(sm.id) as id, sm.location_dest_id as location_id, sm.product_id, sm.tracking_id, sum(sm.product_qty /uo.factor) as qty from stock_move as sm left join stock_location sl on (sl.id = sm.location_dest_id) left join product_uom uo on (uo.id=sm.product_uom) where sm.state = 'done' group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.tracking_id ) as report group by location_id, product_id, tracking_id )""") |
drop_view_if_exists(cr, 'stock_report_prodlots') | drop_view_if_exists(cr, 'report_stock_lines_date') | def init(self, cr): drop_view_if_exists(cr, 'stock_report_prodlots') cr.execute(""" create or replace view report_stock_lines_date as ( select p.id as id, p.id as product_id, max(s.date) as date from product_product p left outer join stock_inventory_line l on (p.id=l.product_id) left join stock_inventory s on (l.inventory_id=s.id) and s.state = 'done' group by p.id )""") |
return 1 | res = res.values() return len(res) and res[0] or 0 | def action_produce_assign_product(self, cr, uid, ids, context={}): """ @summary : This is action which call from workflow to assign production order to procuments @return : True """ res = self.make_mo(cr, uid, ids, context=context) return 1 #TO CHECK: why workflow is generated error if return True |
return 1 | res = res.values() return len(res) and res[0] or 0 | def action_po_assign(self, cr, uid, ids, context={}): """ @summary : This is action which call from workflow to assign purchase order to procuments @return : True """ res = self.make_po(cr, uid, ids, context=context) return 1 #TO CHECK: why workflow is generated error if return True |
product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context) | product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','standard_price')], context=context) | def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id, unit=False, journal_id=False, context=None): if context==None: context={} if not journal_id: j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=','purchase')]) journal_id = j_ids and j_ids[0] or False if not journal_id or not prod_id: return {} product_obj = self.pool.get('product.product') analytic_journal_obj =self.pool.get('account.analytic.journal') |
value = { 'duration': 24 } duration = 0.0 | value = {'duration': 24} duration = 24.0 | def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, allday=False, context=None): """Returns duration and/or end date based on values passed @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 calendar event’s IDs. @param start_date: Starting date @param duration: Duration between start date and end date @param end_date: Ending Datee @param context: A standard dictionary for contextual values """ if context is None: context = {} |
elif end_date and duration: | elif end_date and duration and not allday: | def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, allday=False, context=None): """Returns duration and/or end date based on values passed @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 calendar event’s IDs. @param start_date: Starting date @param duration: Duration between start date and end date @param end_date: Ending Datee @param context: A standard dictionary for contextual values """ if context is None: context = {} |
ret.setdefault(key, []).extend(val) | if key in ret: ret[key] = ret[key][:] else: ret[key] = [] ret[key].extend(val) | def prep_http_options(self, uri, opts): """see HttpOptions._prep_OPTIONS """ self.parent.log_message('get options: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True) |
and not (isinstance(model_pool._columns[x[0]],fields.function) or isinstance(model_pool._columns[x[0]],fields.related)), fields_get.items())) | and not (isinstance(model_columns[x[0]],fields.function) or isinstance(model_columns[x[0]],fields.related)), fields_get.items())) | def _path_get(self,cr, uid, models, filter_ids=[]): |
str_where = model_dict.get(model)+"."+ k + "=" + model_dict.get(v.get('relation'))+'.id' where_list.append(str_where) | if k in self.pool.get(model)._columns: str_where = model_dict.get(model)+"."+ k + "=" + model_dict.get(v.get('relation'))+'.id' where_list.append(str_where) | def _path_get(self,cr, uid, models, filter_ids=[]): |
data_lines = invoice.move_id.line_id | data_lines = [x for x in invoice.move_id.line_id if x.account_id.id == invoice.account_id.id] | def _get_lines(self, cr, uid, ids, name, arg, context=None): res = {} for invoice in self.browse(cr, uid, ids, context=context): id = invoice.id res[id] = [] if not invoice.move_id: continue data_lines = invoice.move_id.line_id partial_ids = [] for line in data_lines: ids_line = [] if line.reconcile_id: ids_line = line.reconcile_id.line_id elif line.reconcile_partial_id: ids_line = line.reconcile_partial_id.line_partial_ids l = map(lambda x: x.id, ids_line) partial_ids.append(line.id) res[id] =[x for x in l if x <> line.id and x not in partial_ids] return res |
if form['display_account'] == 'movement': | if form['display_account'] == 'bal_movement': | def get_children_accounts(self, account, form): res = [] ids_acc = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, account.id) for child_account in self.pool.get('account.account').browse(self.cr, self.uid, ids_acc): sql = """ SELECT count(id) FROM account_move_line l WHERE %s AND l.account_id = %%s """ % (self.query) self.cr.execute(sql, (child_account.id,)) num_entry = self.cr.fetchone()[0] or 0 sold_account = self._sum_balance_account(child_account,form) self.sold_accounts[child_account.id] = sold_account if form['display_account'] == 'movement': if child_account.type != 'view' and num_entry <> 0 : res.append(child_account) elif form['display_account'] == 'balance': if child_account.type != 'view' and num_entry <> 0 : if ( sold_account <> 0.0): res.append(child_account) else: res.append(child_account) if not len(res): return [account] return res |
elif form['display_account'] == 'balance': | elif form['display_account'] == 'bal_solde': | def get_children_accounts(self, account, form): res = [] ids_acc = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, account.id) for child_account in self.pool.get('account.account').browse(self.cr, self.uid, ids_acc): sql = """ SELECT count(id) FROM account_move_line l WHERE %s AND l.account_id = %%s """ % (self.query) self.cr.execute(sql, (child_account.id,)) num_entry = self.cr.fetchone()[0] or 0 sold_account = self._sum_balance_account(child_account,form) self.sold_accounts[child_account.id] = sold_account if form['display_account'] == 'movement': if child_account.type != 'view' and num_entry <> 0 : res.append(child_account) elif form['display_account'] == 'balance': if child_account.type != 'view' and num_entry <> 0 : if ( sold_account <> 0.0): res.append(child_account) else: res.append(child_account) if not len(res): return [account] return res |
id = super(wiki_wiki2, self).create(cr, uid, vals, context) | id = super(wiki_wiki2, self).create(cr, uid, {'create_id':vals.get('create_id',''), 'name':vals.get('name',''), 'minor_edit':vals.get('minor_edit',''), 'review':vals.get('review',''), 'write_uid':vals.get('write_uid',''), 'parent_id':vals.get('parent_id',''), 'text_area':vals.get('text_area',''), 'toc':vals.get('toc',''), 'group_id':vals.get('group_id',''), 'section':vals.get('section','',)}, context) | def create(self, cr, uid, vals, context=None): |
new_cc = '' | new_cc = [] | def action_forward(self, cr, uid, ids, context=None): """ Forward the lead to a partner """ this = self.browse(cr, uid, ids[0], context=context) case_pool = self.pool.get(context.get('active_model')) res_id = context and context.get('active_id', False) or False case = case_pool.browse(cr, uid, res_id, context=context) |
new_cc += ', ' + to to_write.update({'email_cc' : case.email_cc and case.email_cc + new_cc}) | new_cc.append(to) to_write.update({'email_cc' : case.email_cc or '' + ','.join(new_cc)}) | def action_forward(self, cr, uid, ids, context=None): """ Forward the lead to a partner """ this = self.browse(cr, uid, ids[0], context=context) case_pool = self.pool.get(context.get('active_model')) res_id = context and context.get('active_id', False) or False case = case_pool.browse(cr, uid, res_id, context=context) |
(_check_dates, 'Error! Task start-date must be lower then task end-date.', ['date_start', 'date_end']), | def _check_recursion(self, cr, uid, ids): obj_task = self.browse(cr, uid, ids[0]) parent_ids = [x.id for x in obj_task.parent_ids] children_ids = [x.id for x in obj_task.child_ids] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.