rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
def action_done(self, cr, uid, ids, context=None): | def action_done(self, cr, uid, ids, context={}): | def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] 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) |
product_uom_obj = self.pool.get('product.uom') | def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] 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) |
|
company_id=move.company_id.id context['currency_id']=move.company_id.currency_id.id pricetype=self.pool.get('product.price.type').browse(cr,uid,move.company_id.property_valuation_price_type.id) amount_unit=move.product_id.price_get(pricetype.field, context)[move.product_id.id] amount=amount_unit * q or 1.0 | company_id = move.company_id.id context['currency_id'] = move.company_id.currency_id.id pricetype = price_type_obj.browse(cr,uid,move.company_id.property_valuation_price_type.id) amount_unit = move.product_id.price_get(pricetype.field, context)[move.product_id.id] amount = amount_unit * q or 1.0 | def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] 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) |
self.pool.get('account.move').create(cr, uid, { | move_obj.create(cr, uid, { | def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] 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) |
tracking_id = context.get('tracking_id', False) if tracking_id: tracking = self.pool.get('stock.tracking') tracking_id = tracking.get_create_tracking_lot(cr, uid,[rec_id], context=context ) self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S'), 'tracking_id': tracking_id}) for pick in self.pool.get('stock.picking').browse(cr, uid, picking_ids): | tracking_id = False if context: tracking_id = context.get('tracking_id', False) if tracking_id: rec_id = context and context.get('active_id', False) tracking = self.pool.get('stock.tracking') tracking_id = tracking.get_create_tracking_lot(cr, uid,[rec_id], context=context ) self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S'), 'tracking_id': tracking_id or False}) picking_obj = self.pool.get('stock.picking') for pick in picking_obj.browse(cr, uid, picking_ids): | def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] 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) |
self.pool.get('stock.picking').action_done(cr, uid, [pick.id]) | picking_obj.action_done(cr, uid, [pick.id]) | def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] 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) |
val_invoice = pool_obj.get('account.invoice').onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False) | val_invoice = inv_obj.onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False) | def _makeInvoices(self, cr, uid, context={}): invoices = {} invoice_ids = [] create_ids=[] tax_ids=[] inv_create = 0 inv_reject = 0 inv_rej_reason = "" list_inv = [] obj_event_reg = self.pool.get('event.registration') obj_lines = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') data_event_reg = obj_event_reg.browse(cr,uid, context['active_ids'], context=context) |
journal_id = context['journal_id'] period_id = context['period_id'] journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date: period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) | 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'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) | def _check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} 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['journal_id'] period_id = context['period_id'] journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date: period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) else: return True |
lang=part.lang context.update({'lang': lang}) | if part.lang: context.update({'lang': part.lang}) | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False |
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None): | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None): # note: will call product_id_change_unit_price_inv with context... |
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, context=ctx) | return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id=currency_id, context=ctx) | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None): # note: will call product_id_change_unit_price_inv with context... |
"AND " + self.query +" " \ | def set_context(self, objects, data, ids, report_type=None): obj_move = self.pool.get('account.move.line') self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {})) ctx2 = data['form'].get('used_context',{}).copy() ctx2.update({'initial_bal': True}) self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2) self.reconcil = data['form'].get('reconcil', True) self.initial_balance = data['form'].get('initial_balance', True) self.result_selection = data['form'].get('result_selection', 'customer') self.amount_currency = data['form'].get('amount_currency', False) self.target_move = data['form'].get('target_move', 'all') PARTNER_REQUEST = '' move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
|
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids) | objects = obj_partner.browse(self.cr, self.uid, new_ids) | def set_context(self, objects, data, ids, report_type=None): obj_move = self.pool.get('account.move.line') self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {})) ctx2 = data['form'].get('used_context',{}).copy() ctx2.update({'initial_bal': True}) self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2) self.reconcil = data['form'].get('reconcil', True) self.initial_balance = data['form'].get('initial_balance', True) self.result_selection = data['form'].get('result_selection', 'customer') self.amount_currency = data['form'].get('amount_currency', False) self.target_move = data['form'].get('target_move', 'all') PARTNER_REQUEST = '' move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
ids = [x[1] for x in data['form']['pickings']] | ids = data['form']['pickings'][0][2] | def _make_packing(obj, cursor, user, data, context): wkf_service = netsvc.LocalService('workflow') pool = pooler.get_pool(cursor.dbname) picking_obj = pool.get('stock.picking') ids = [x[1] for x in data['form']['pickings']] picking_obj.force_assign(cursor, user, ids) picking_obj.action_move(cursor, user, ids) for picking_id in ids: wkf_service.trg_validate(user, 'stock.picking', picking_id, 'button_done', cursor) return {} |
return open(os.path.join( tools.config['addons_path'], 'hr/image', 'photo.png'), 'rb') .read().encode('base64') | paths = tools.config['addons_path'].split(",") for path in paths: full_path = os.path.join(path, 'hr/image', 'photo.png') if os.path.exists(full_path): return open(full_path,'rb') .read().encode('base64') raise Exception("photo.png could not be found") | def _get_photo(self, cr, uid, context=None): return open(os.path.join( tools.config['addons_path'], 'hr/image', 'photo.png'), 'rb') .read().encode('base64') |
if not company_id or 'company_id' in defaults: return defaults | if not company_id or 'company_id' not in fields_list: return defaults | def default_get(self, cr, uid, fields_list=None, context=None): """ get default company if any, and the various other fields from the company's fields """ defaults = super(base_setup_company, self)\ .default_get(cr, uid, fields_list=fields_list, context=context) |
def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): """Modifies only one event record out of virtual recurrent events and creates new event as a specific instance of a Recurring Event", @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 event_id: Id of Recurring Event @param real_date: Date of event recurrence that is being modified @param context: A standard dictionary for contextual values @param *args: Get Tupple Value """ event_id = base_calendar_id2real_id(event_id) defaults.update({ 'recurrent_uid': base_calendar_id2real_id(event_id), 'recurrent_id': real_date, 'rrule_type': 'none', 'rrule': '' }) new_id = self.copy(cr, uid, event_id, default=defaults, context=context) return new_id | def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): """Modifies only one event record out of virtual recurrent events and creates new event as a specific instance of a Recurring Event", @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 event_id: Id of Recurring Event @param real_date: Date of event recurrence that is being modified @param context: A standard dictionary for contextual values @param *args: Get Tupple Value """ |
|
real_date = data.get('date') data.update(vals) new_id = self.modify_this(cr, uid, event_id, data, \ real_date, context) | vals.update({ 'recurrent_uid': real_event_id, 'recurrent_id': data.get('date'), 'rrule_type': 'none', 'rrule': '' }) new_id = self.copy(cr, uid, real_event_id, default=vals, context=context) | def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): """ Overrides orm write method. @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 crm meeting's ids @param vals: Dictionary of field value. @param context: A standard dictionary for contextual values @return: True """ if not context: context = {} if isinstance(ids, (str, int, long)): select = [ids] else: select = ids new_ids = [] for event_id in select: if len(str(event_id).split('-')) > 1: data = self.read(cr, uid, event_id, ['date', 'date_deadline', \ 'rrule', 'duration']) if data.get('rrule'): real_date = data.get('date') data.update(vals) new_id = self.modify_this(cr, uid, event_id, data, \ real_date, context) context.update({'active_id': new_id, 'active_ids': [new_id]}) continue event_id = base_calendar_id2real_id(event_id) if not event_id in new_ids: new_ids.append(event_id) |
event_id = base_calendar_id2real_id(event_id) if not event_id in new_ids: new_ids.append(event_id) | if not real_event_id in new_ids: new_ids.append(real_event_id) | def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): """ Overrides orm write method. @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 crm meeting's ids @param vals: Dictionary of field value. @param context: A standard dictionary for contextual values @return: True """ if not context: context = {} if isinstance(ids, (str, int, long)): select = [ids] else: select = ids new_ids = [] for event_id in select: if len(str(event_id).split('-')) > 1: data = self.read(cr, uid, event_id, ['date', 'date_deadline', \ 'rrule', 'duration']) if data.get('rrule'): real_date = data.get('date') data.update(vals) new_id = self.modify_this(cr, uid, event_id, data, \ real_date, context) context.update({'active_id': new_id, 'active_ids': [new_id]}) continue event_id = base_calendar_id2real_id(event_id) if not event_id in new_ids: new_ids.append(event_id) |
bank_statement = {} | def _coda_parsing(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) codafile = data['form']['coda'] journal_code = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context).code def_pay_acc = data['form']['def_payable'] def_rec_acc = data['form']['def_receivable'] str_log = "" err_log = "Errors:\n------\n" nb_err=0 std_log='' str_log1 = "Coda File is Imported : " str_not='' str_not1='' bank_statements=[] recordlist = base64.decodestring(codafile).split('\n') recordlist.pop() for line in recordlist: if line[0] == '0': # header data bank_statement = {} bank_statement["bank_statement_line"]={} bank_statement_lines = {} bank_statement['date'] = str2date(line[5:11]) bank_statement['journal_id']=data['form']['journal_id'] period_id = pool.get('account.period').search(cr, uid, [('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))]) bank_statement['period_id'] = period_id and period_id[0] or False bank_statement['state']='draft' elif line[0] == '1': # old balance data bal_start = list2float(line[43:58]) if line[42] == '1': bal_start = - bal_start bank_statement["balance_start"]= bal_start bank_statement["acc_number"]=line[5:17] bank_statement["acc_holder"]=line[64:90] bank_statement['name'] = journal_code + ' ' + str(line[2:5]) elif line[0]=='2': # movement data record 2 if line[1]=='1': # movement data record 2.1 if bank_statement_lines.has_key(line[2:6]): continue st_line = {} st_line['extra_note'] = '' st_line['statement_id']=0 st_line['ref'] = line[2:10] st_line['date'] = time.strftime('%Y-%m-%d',time.strptime(str2date(line[115:121]),"%y/%m/%d")), st_line_amt = list2float(line[32:47]) if line[61]=='1': st_line['toreconcile'] = True st_line['name']=line[65:77] else: st_line['toreconcile'] = False st_line['name']=line[62:115] st_line['free_comm'] = st_line['name'] st_line['val_date']=time.strftime('%Y-%m-%d',time.strptime(str2date(line[47:53]),"%y/%m/%d")), st_line['entry_date']=time.strftime('%Y-%m-%d',time.strptime(str2date(line[115:121]),"%y/%m/%d")), st_line['partner_id']=0 if line[31] == '1': st_line_amt = - st_line_amt st_line['account_id'] = def_pay_acc else: st_line['account_id'] = def_rec_acc st_line['amount'] = st_line_amt bank_statement_lines[line[2:6]]=st_line bank_statement["bank_statement_line"]=bank_statement_lines elif line[1] == '2': st_line_name = line[2:6] bank_statement_lines[st_line_name].update({'account_id': data['form']['awaiting_account']}) elif line[1] == '3': # movement data record 3.1 st_line_name = line[2:6] st_line_partner_acc = str(line[10:47]).strip() cntry_number=line[10:47].strip() contry_name=line[47:125].strip() bank_ids = pool.get('res.partner.bank').search(cr, uid, [('acc_number','=',st_line_partner_acc)]) bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name}) if bank_ids: bank = pool.get('res.partner.bank').browse(cr, uid, bank_ids[0], context) if line and bank.partner_id: bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id}) if bank_statement_lines[st_line_name]['amount'] < 0 : bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_payable.id}) else : bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_receivable.id}) else: nb_err += 1 err_log += _('The bank account %s is not defined for the partner %s.\n')%(cntry_number,contry_name) bank_statement_lines[st_line_name].update({'account_id': data['form']['awaiting_account']}) bank_statement["bank_statement_line"]=bank_statement_lines elif line[0]=='3': if line[1] == '1': st_line_name = line[2:6] bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[40:113] elif line[1] == '2': st_line_name = line[2:6] bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:115] elif line[1] == '3': st_line_name = line[2:6] bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:100] elif line[0]=='8': # new balance record bal_end = list2float(line[42:57]) if line[41] == '1': bal_end = - bal_end bank_statement["balance_end_real"]= bal_end elif line[0]=='9': # footer record bank_statements.append(bank_statement) #end for bkst_list=[] for statement in bank_statements: try: bk_st_id = pool.get('account.bank.statement').create(cr,uid,{ 'journal_id': statement['journal_id'], 'date':time.strftime('%Y-%m-%d',time.strptime(statement['date'],"%y/%m/%d")), 'period_id':statement['period_id'], 'balance_start': statement["balance_start"], 'balance_end_real': statement["balance_end_real"], 'state': 'draft', 'name': statement['name'], }) lines=statement["bank_statement_line"] for value in lines: line=lines[value] reconcile_id = False if line['toreconcile']: rec_id = pool.get('account.move.line').search(cr, uid, [('name','=',line['name']),('reconcile_id','=',False),('account_id.reconcile','=',True)]) if rec_id: reconcile_id = pool.get('account.bank.statement.reconcile').create(cr, uid, { 'line_ids': [(6, 0, rec_id)] }, context=context) str_not1 = '' if line.has_key('contry_name') and line.has_key('cntry_number'): str_not1="Partner name:%s \n Partner Account Number:%s \n Communication:%s \n Value Date:%s \n Entry Date:%s \n"%(line["contry_name"],line["cntry_number"],line["free_comm"]+line['extra_note'],line["val_date"][0],line["entry_date"][0]) id=pool.get('account.bank.statement.line').create(cr,uid,{ 'name':line['name'], 'date': line['date'], 'amount': line['amount'], 'partner_id':line['partner_id'] or 0, 'account_id':line['account_id'], 'statement_id': bk_st_id, 'reconcile_id': reconcile_id, 'note':str_not1, 'ref':line['ref'], }) str_not= "\n \n Account Number: %s \n Account Holder Name: %s " %(statement["acc_number"],statement["acc_holder"]) std_log += "\nStatement : %s , Date : %s, Starting Balance : %.2f , Ending Balance : %.2f \n"\ %(statement['name'], statement['date'], float(statement["balance_start"]), float(statement["balance_end_real"])) bkst_list.append(bk_st_id) except osv.except_osv, e: cr.rollback() nb_err+=1 err_log += '\n Application Error : ' + str(e) raise # REMOVEME except Exception, e: cr.rollback() nb_err+=1 err_log += '\n System Error : '+str(e) raise # REMOVEME except : cr.rollback() nb_err+=1 err_log += '\n Unknown Error' raise err_log += '\n\nNumber of statements : '+ str(len(bkst_list)) err_log += '\nNumber of error :'+ str(nb_err) +'\n' pool.get('account.coda').create(cr, uid, { 'name':codafile, 'statement_ids': [(6, 0, bkst_list,)], 'note':str_log1+str_not+std_log+err_log, 'journal_id':data['form']['journal_id'], 'date':time.strftime("%Y-%m-%d"), 'user_id':uid, }) return {'note':str_log1 + std_log + err_log ,'journal_id': data['form']['journal_id'], 'coda': data['form']['coda'],'statment_ids':bkst_list} |
|
'period_id':statement['period_id'], | 'period_id':statement['period_id'] or period, | def _coda_parsing(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) codafile = data['form']['coda'] journal_code = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context).code def_pay_acc = data['form']['def_payable'] def_rec_acc = data['form']['def_receivable'] str_log = "" err_log = "Errors:\n------\n" nb_err=0 std_log='' str_log1 = "Coda File is Imported : " str_not='' str_not1='' bank_statements=[] recordlist = base64.decodestring(codafile).split('\n') recordlist.pop() for line in recordlist: if line[0] == '0': # header data bank_statement = {} bank_statement["bank_statement_line"]={} bank_statement_lines = {} bank_statement['date'] = str2date(line[5:11]) bank_statement['journal_id']=data['form']['journal_id'] period_id = pool.get('account.period').search(cr, uid, [('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))]) bank_statement['period_id'] = period_id and period_id[0] or False bank_statement['state']='draft' elif line[0] == '1': # old balance data bal_start = list2float(line[43:58]) if line[42] == '1': bal_start = - bal_start bank_statement["balance_start"]= bal_start bank_statement["acc_number"]=line[5:17] bank_statement["acc_holder"]=line[64:90] bank_statement['name'] = journal_code + ' ' + str(line[2:5]) elif line[0]=='2': # movement data record 2 if line[1]=='1': # movement data record 2.1 if bank_statement_lines.has_key(line[2:6]): continue st_line = {} st_line['extra_note'] = '' st_line['statement_id']=0 st_line['ref'] = line[2:10] st_line['date'] = time.strftime('%Y-%m-%d',time.strptime(str2date(line[115:121]),"%y/%m/%d")), st_line_amt = list2float(line[32:47]) if line[61]=='1': st_line['toreconcile'] = True st_line['name']=line[65:77] else: st_line['toreconcile'] = False st_line['name']=line[62:115] st_line['free_comm'] = st_line['name'] st_line['val_date']=time.strftime('%Y-%m-%d',time.strptime(str2date(line[47:53]),"%y/%m/%d")), st_line['entry_date']=time.strftime('%Y-%m-%d',time.strptime(str2date(line[115:121]),"%y/%m/%d")), st_line['partner_id']=0 if line[31] == '1': st_line_amt = - st_line_amt st_line['account_id'] = def_pay_acc else: st_line['account_id'] = def_rec_acc st_line['amount'] = st_line_amt bank_statement_lines[line[2:6]]=st_line bank_statement["bank_statement_line"]=bank_statement_lines elif line[1] == '2': st_line_name = line[2:6] bank_statement_lines[st_line_name].update({'account_id': data['form']['awaiting_account']}) elif line[1] == '3': # movement data record 3.1 st_line_name = line[2:6] st_line_partner_acc = str(line[10:47]).strip() cntry_number=line[10:47].strip() contry_name=line[47:125].strip() bank_ids = pool.get('res.partner.bank').search(cr, uid, [('acc_number','=',st_line_partner_acc)]) bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name}) if bank_ids: bank = pool.get('res.partner.bank').browse(cr, uid, bank_ids[0], context) if line and bank.partner_id: bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id}) if bank_statement_lines[st_line_name]['amount'] < 0 : bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_payable.id}) else : bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_receivable.id}) else: nb_err += 1 err_log += _('The bank account %s is not defined for the partner %s.\n')%(cntry_number,contry_name) bank_statement_lines[st_line_name].update({'account_id': data['form']['awaiting_account']}) bank_statement["bank_statement_line"]=bank_statement_lines elif line[0]=='3': if line[1] == '1': st_line_name = line[2:6] bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[40:113] elif line[1] == '2': st_line_name = line[2:6] bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:115] elif line[1] == '3': st_line_name = line[2:6] bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:100] elif line[0]=='8': # new balance record bal_end = list2float(line[42:57]) if line[41] == '1': bal_end = - bal_end bank_statement["balance_end_real"]= bal_end elif line[0]=='9': # footer record bank_statements.append(bank_statement) #end for bkst_list=[] for statement in bank_statements: try: bk_st_id = pool.get('account.bank.statement').create(cr,uid,{ 'journal_id': statement['journal_id'], 'date':time.strftime('%Y-%m-%d',time.strptime(statement['date'],"%y/%m/%d")), 'period_id':statement['period_id'], 'balance_start': statement["balance_start"], 'balance_end_real': statement["balance_end_real"], 'state': 'draft', 'name': statement['name'], }) lines=statement["bank_statement_line"] for value in lines: line=lines[value] reconcile_id = False if line['toreconcile']: rec_id = pool.get('account.move.line').search(cr, uid, [('name','=',line['name']),('reconcile_id','=',False),('account_id.reconcile','=',True)]) if rec_id: reconcile_id = pool.get('account.bank.statement.reconcile').create(cr, uid, { 'line_ids': [(6, 0, rec_id)] }, context=context) str_not1 = '' if line.has_key('contry_name') and line.has_key('cntry_number'): str_not1="Partner name:%s \n Partner Account Number:%s \n Communication:%s \n Value Date:%s \n Entry Date:%s \n"%(line["contry_name"],line["cntry_number"],line["free_comm"]+line['extra_note'],line["val_date"][0],line["entry_date"][0]) id=pool.get('account.bank.statement.line').create(cr,uid,{ 'name':line['name'], 'date': line['date'], 'amount': line['amount'], 'partner_id':line['partner_id'] or 0, 'account_id':line['account_id'], 'statement_id': bk_st_id, 'reconcile_id': reconcile_id, 'note':str_not1, 'ref':line['ref'], }) str_not= "\n \n Account Number: %s \n Account Holder Name: %s " %(statement["acc_number"],statement["acc_holder"]) std_log += "\nStatement : %s , Date : %s, Starting Balance : %.2f , Ending Balance : %.2f \n"\ %(statement['name'], statement['date'], float(statement["balance_start"]), float(statement["balance_end_real"])) bkst_list.append(bk_st_id) except osv.except_osv, e: cr.rollback() nb_err+=1 err_log += '\n Application Error : ' + str(e) raise # REMOVEME except Exception, e: cr.rollback() nb_err+=1 err_log += '\n System Error : '+str(e) raise # REMOVEME except : cr.rollback() nb_err+=1 err_log += '\n Unknown Error' raise err_log += '\n\nNumber of statements : '+ str(len(bkst_list)) err_log += '\nNumber of error :'+ str(nb_err) +'\n' pool.get('account.coda').create(cr, uid, { 'name':codafile, 'statement_ids': [(6, 0, bkst_list,)], 'note':str_log1+str_not+std_log+err_log, 'journal_id':data['form']['journal_id'], 'date':time.strftime("%Y-%m-%d"), 'user_id':uid, }) return {'note':str_log1 + std_log + err_log ,'journal_id': data['form']['journal_id'], 'coda': data['form']['coda'],'statment_ids':bkst_list} |
(sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty/u.factor)*count(l.product_id))::decimal(16,2) as price_average, | def init(self, cr): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( select el.*, -- (select count(1) from sale_order_line where order_id = s.id) as nbr, (select 1) as nbr, s.date_order as date, s.date_confirm as date_confirm, to_char(s.date_order, 'YYYY') as year, to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.user_id as user_id, s.shop_id as shop_id, s.company_id as company_id, extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, s.shipped, s.shipped::integer as shipped_qty_1, s.pricelist_id as pricelist_id, s.project_id as analytic_account_id from sale_order s, ( select l.id as id, l.product_id as product_id, (case when u.uom_type not in ('reference') then (select name from product_uom where uom_type='reference' and category_id=u.category_id) else u.name end) as uom_name, sum(l.product_uom_qty/u.factor) as product_uom_qty, sum(l.product_uom_qty*l.price_unit) as price_total, (sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty/u.factor)*count(l.product_id))::decimal(16,2) as price_average, pt.categ_id, l.order_id from sale_order_line l left join product_uom u on (u.id=l.product_uom) left join product_template pt on (pt.id=l.product_id) group by l.id, l.order_id, l.product_id, u.name, pt.categ_id, u.uom_type, u.category_id) el where s.id = el.order_id group by el.id, el.product_id, el.uom_name, el.product_uom_qty, el.price_total, el.price_average, el.categ_id, el.order_id, s.date_order, s.date_confirm, s.partner_id, s.user_id, s.shop_id, s.company_id, s.state, s.shipped, s.pricelist_id, s.project_id ) """) |
|
el.price_average, | def init(self, cr): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( select el.*, -- (select count(1) from sale_order_line where order_id = s.id) as nbr, (select 1) as nbr, s.date_order as date, s.date_confirm as date_confirm, to_char(s.date_order, 'YYYY') as year, to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, s.partner_id as partner_id, s.user_id as user_id, s.shop_id as shop_id, s.company_id as company_id, extract(epoch from avg(date_trunc('day',s.date_confirm)-date_trunc('day',s.create_date)))/(24*60*60)::decimal(16,2) as delay, s.state, s.shipped, s.shipped::integer as shipped_qty_1, s.pricelist_id as pricelist_id, s.project_id as analytic_account_id from sale_order s, ( select l.id as id, l.product_id as product_id, (case when u.uom_type not in ('reference') then (select name from product_uom where uom_type='reference' and category_id=u.category_id) else u.name end) as uom_name, sum(l.product_uom_qty/u.factor) as product_uom_qty, sum(l.product_uom_qty*l.price_unit) as price_total, (sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty/u.factor)*count(l.product_id))::decimal(16,2) as price_average, pt.categ_id, l.order_id from sale_order_line l left join product_uom u on (u.id=l.product_uom) left join product_template pt on (pt.id=l.product_id) group by l.id, l.order_id, l.product_id, u.name, pt.categ_id, u.uom_type, u.category_id) el where s.id = el.order_id group by el.id, el.product_id, el.uom_name, el.product_uom_qty, el.price_total, el.price_average, el.categ_id, el.order_id, s.date_order, s.date_confirm, s.partner_id, s.user_id, s.shop_id, s.company_id, s.state, s.shipped, s.pricelist_id, s.project_id ) """) |
|
'get_end_date':self._get_end_date, | 'get_end_date':self._get_end_date, 'print_data':self._print_data, | 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_fiscalyear': self._get_fiscalyear, 'get_account': self._get_account, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_sortby': self._get_sortby, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_filter': self._get_filter, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, }) |
purchase_obj = self.pool.get('purchase.order') | def makeInvoices(self, cr, uid, ids, context=None): |
|
'model': fields.char('Object Name', size=64, required=True), | 'model': fields.char('Object Name', size=64, required=True, select=1), | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) groups = self.pool.get('res.groups').search(cr, uid, []) groups_br = self.pool.get('res.groups').browse(cr, uid, groups) cols = ['model', 'name'] xml = '''<?xml version="1.0"?> |
'state': fields.selection([('manual','Custom Field'),('base','Base Field')],'Manually Created', required=True, readonly=True), | 'state': fields.selection([('manual','Custom Field'),('base','Base Field')],'Manually Created', required=True, readonly=True, select=1), | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) groups = self.pool.get('res.groups').search(cr, uid, []) groups_br = self.pool.get('res.groups').browse(cr, uid, groups) cols = ['model', 'name'] xml = '''<?xml version="1.0"?> |
'name': fields.char('Name', size=64, required=True), 'model_id': fields.many2one('ir.model', 'Object', required=True, domain=[('osv_memory','=', False)]), 'group_id': fields.many2one('res.groups', 'Group', ondelete='cascade'), | 'name': fields.char('Name', size=64, required=True, select=True), 'model_id': fields.many2one('ir.model', 'Object', required=True, domain=[('osv_memory','=', False)], select=True), 'group_id': fields.many2one('res.groups', 'Group', ondelete='cascade', select=True), | def create(self, cr, user, vals, context=None): if 'model_id' in vals: model_data = self.pool.get('ir.model').browse(cr, user, vals['model_id']) vals['model'] = model_data.model if context is None: context = {} if context and context.get('manual',False): vals['state'] = 'manual' res = super(ir_model_fields,self).create(cr, user, vals, context) if vals.get('state','base') == 'manual': if not vals['name'].startswith('x_'): raise except_orm(_('Error'), _("Custom fields must have a name that starts with 'x_' !")) |
'name': fields.char('XML Identifier', required=True, size=128), 'model': fields.char('Object', required=True, size=64), 'module': fields.char('Module', required=True, size=64), 'res_id': fields.integer('Resource ID'), | 'name': fields.char('XML Identifier', required=True, size=128, select=1), 'model': fields.char('Object', required=True, size=64, select=1), 'module': fields.char('Module', required=True, size=64, select=1), 'res_id': fields.integer('Resource ID', select=1), | def unlink(self, cr, uid, *args, **argv): self.call_cache_clearing_methods(cr) res = super(ir_model_access, self).unlink(cr, uid, *args, **argv) return res |
nyear = next_date.strftime("%Y") nmonth = str(int(next_date.strftime("%m"))% 12+1) nday = "1" ndate = "%s-%s-%s" % (nyear, nmonth, nday) nseconds = time.mktime(time.strptime(ndate, '%Y-%m-%d')) next_month = datetime.fromtimestamp(nseconds) delta = timedelta(seconds=1) next_date = next_month - delta next_date = next_date + relativedelta(days=line.days2) | next_first_date = next_date + relativedelta(day=1,months=1) next_date = next_first_date + relativedelta(days=line.days2) | def compute(self, cr, uid, id, value, date_ref=False, context=None): if not date_ref: date_ref = datetime.now().strftime('%Y-%m-%d') pt = self.browse(cr, uid, id, context=context) amount = value result = [] obj_precision = self.pool.get('decimal.precision') for line in pt.line_ids: prec = obj_precision.precision_get(cr, uid, 'Account') if line.value == 'fixed': amt = round(line.value_amount, prec) elif line.value == 'procent': amt = round(value * line.value_amount, prec) elif line.value == 'balance': amt = round(amount, prec) if amt: next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days)) if line.days2 < 0: nyear = next_date.strftime("%Y") nmonth = str(int(next_date.strftime("%m"))% 12+1) nday = "1" |
rcal = self.export_cal(cr, uid, rdata, context=context) | event_obj = self.pool.get('basic.calendar.event') rcal = event_obj.export_cal(cr, uid, rdata, context=context) | def create_ics(self, cr, uid, datas, name, ical, context=None): if not datas: return for data in datas: vevent = ical.add(name) for field in self.__attribute__.keys(): map_field = self.ical_get(field, 'field') map_type = self.ical_get(field, 'type') if map_field in data.keys(): if field == 'uid': model = context.get('model', None) if not model: continue uidval = openobjectid2uid(cr, data[map_field], model) model_obj = self.pool.get(model) r_ids = [] if model_obj._columns.get('recurrent_uid', None): cr.execute('select id from %s where recurrent_uid=%s' % (model_obj._table, data[map_field])) r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: rdata = self.pool.get(model).read(cr, uid, r_ids) rcal = self.export_cal(cr, uid, rdata, context=context) for revents in rcal.contents['vevent']: ical.contents['vevent'].append(revents) if data.get('recurrent_uid', None): uidval = openobjectid2uid(cr, data['recurrent_uid'], model) vevent.add('uid').value = uidval elif field == 'attendee' and data[map_field]: model = self.__attribute__[field].get('object', False) attendee_obj = self.pool.get('basic.calendar.attendee') vevent = attendee_obj.export_cal(cr, uid, model, \ data[map_field], vevent, context=context) elif field == 'valarm' and data[map_field]: model = self.__attribute__[field].get('object', False) ctx = context.copy() ctx.update({'model': model}) alarm_obj = self.pool.get('basic.calendar.alarm') vevent = alarm_obj.export_cal(cr, uid, model, \ data[map_field][0], vevent, context=ctx) elif data[map_field]: if map_type in ("char", "text"): vevent.add(field).value = tools.ustr(data[map_field]) elif map_type in ('datetime', 'date') and data[map_field]: if field in ('exdate'): vevent.add(field).value = [parser.parse(data[map_field])] else: vevent.add(field).value = parser.parse(data[map_field]) elif map_type == "timedelta": vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": vevent.add(field).value = tools.ustr(data.get(map_field)[1]) elif map_type in ("float", "integer"): vevent.add(field).value = str(data.get(map_field)) elif map_type == "selection": if not self.ical_get(field, 'mapping'): vevent.add(field).value = (tools.ustr(data[map_field])).upper() else: for key1, val1 in self.ical_get(field, 'mapping').items(): if val1 == data[map_field]: vevent.add(field).value = key1 return vevent |
vevent.add(field).value = key1 | vevent.add(field).value = key1.upper() | def create_ics(self, cr, uid, datas, name, ical, context=None): """ create calendaring and scheduling information @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 context: A standard dictionary for contextual values """ |
name = name[-4] ext = '.ics' | name = name[:-4] ext = True | def _child_get(self, cr, name=False, parent_id=False, domain=None): dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('collection_id','=',self.dir_id)] ext = False if name and name.endswith('.ics'): name = name[-4] ext = '.ics' if name: where.append(('name','=',name)) if not domain: domain = [] where = where + domain fil_obj = dirobj.pool.get('basic.calendar') ids = fil_obj.search(cr,uid,where,context=ctx) res = [] for calender in fil_obj.browse(cr, uid, ids, context=ctx): if not ext: res.append(node_calendar(calender.name, self, self.context, calender)) else: res.append(res_node_calendar(name, self, self.context, calender)) return res |
for calender in fil_obj.browse(cr, uid, ids, context=ctx): if not ext: res.append(node_calendar(calender.name, self, self.context, calender)) else: res.append(res_node_calendar(name, self, self.context, calender)) | for cal in fil_obj.browse(cr, uid, ids, context=ctx): if (not name) or not ext: res.append(node_calendar(cal.name, self, self.context, cal)) if (not name) or ext: res.append(res_node_calendar(cal.name+'.ics', self, self.context, cal)) | def _child_get(self, cr, name=False, parent_id=False, domain=None): dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('collection_id','=',self.dir_id)] ext = False if name and name.endswith('.ics'): name = name[-4] ext = '.ics' if name: where.append(('name','=',name)) if not domain: domain = [] where = where + domain fil_obj = dirobj.pool.get('basic.calendar') ids = fil_obj.search(cr,uid,where,context=ctx) res = [] for calender in fil_obj.browse(cr, uid, ids, context=ctx): if not ext: res.append(node_calendar(calender.name, self, self.context, calender)) else: res.append(res_node_calendar(name, self, self.context, calender)) return res |
res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale'))], limit=1) | res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')), ('refund_journal', '=', refund_journal.get(type_inv, False))], limit=1) | def _get_journal(self, cr, uid, context): if context is None: context = {} type_inv = context.get('type', 'out_invoice') type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'} journal_obj = self.pool.get('account.journal') res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale'))], limit=1) if res: return res[0] else: return False |
ean = pack.ean | ean = pack.ean or _('(n/a)') | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id} |
warn_msg = _("You selected a quantity of %d Units.\nBut it's not compatible with the selected packaging.\nHere is a proposition of quantities according to the packaging: ") % (qty) warn_msg = warn_msg + "\n\n" + _("EAN: ") + str(ean) + _(" Quantity: ") + str(qty_pack) + _(" Type of ul: ") + str(type_ul.name) | warn_msg = _("You selected a quantity of %d Units.\n" "But it's not compatible with the selected packaging.\n" "Here is a proposition of quantities according to the packaging:\n\n" "EAN: %s Quantity: %s Type of ul: %s") % \ (qty, ean, qty_pack, type_ul.name) | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id} |
if 'text' in fields: | if include_original == True and 'text' in fields: | def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('crm.case.history') res_ids = context and context.get('active_ids', []) or [] res = {} for hist in hist_obj.browse(cr, uid, res_ids): model = hist.log_id.model_id.model model_pool = self.pool.get(model) case = model_pool.browse(cr, uid, hist.log_id.res_id) if 'email_to' in fields: res.update({'email_to': case.email_from or hist.email_from or False}) if 'email_from' in fields: res.update({'email_from': (case.section_id and case.section_id.reply_to) or \ (case.user_id and case.user_id.address_id and \ case.user_id.address_id.email) or hist.email_to or tools.config.get('email_from',False)}) if 'text' in fields: header = '-------- Original Message --------' sender = 'From: %s' %(hist.email_from or '') to = 'To: %s' % (hist.email_to or '') sentdate = 'Date: %s' % (hist.date) desc = '\n%s'%(hist.description) original = [header, sender, to, sentdate, desc] original = '\n'.join(original) res['text']=original if 'subject' in fields: res.update({'subject': '[%s] %s' %(str(case.id), case.name or '')}) if 'state' in fields: res['state']='pending' return res |
'amount': fields.float('Total', readonly=True, select=True), | def init(self, cr): tools.drop_view_if_exists(cr, 'report_sales_by_user_pos_month') cr.execute(""" create or replace view report_sales_by_user_pos_month as ( select min(po.id) as id, to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text as date_order, po.user_id as user_id, sum(pol.qty)as qty, sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as amount from pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt where pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id group by to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text, po.user_id |
|
'amount': fields.float('Total', readonly=True, select=True), | def init(self, cr): tools.drop_view_if_exists(cr, 'report_sales_by_margin_pos') cr.execute(""" create or replace view report_sales_by_margin_pos as ( select min(pol.id) as id, po.user_id as user_id, pt.name as product_name, to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text as date_order, sum(pol.qty) as qty, pt.list_price-pt.standard_price as net_margin_per_qty, (pt.list_price-pt.standard_price) *sum(pol.qty) as total from product_template as pt, product_product as pp, pos_order_line as pol, pos_order as po where pol.product_id = pp.product_tmpl_id and pp.product_tmpl_id = pt.id and po.id = pol.order_id |
|
select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty | select stock.date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty | def init(self, cr): tools.drop_view_if_exists(cr, 'report_products_to_received_planned') cr.execute(""" create or replace view report_products_to_received_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'in' where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.date |
select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty | select stock.date_planned, min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty | def init(self, cr): tools.drop_view_if_exists(cr, 'report_products_to_received_planned') cr.execute(""" create or replace view report_products_to_received_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'in' where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.date |
select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty | select stock.date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty | def init(self, cr): tools.drop_view_if_exists(cr, 'report_delivery_products_planned') cr.execute(""" create or replace view report_delivery_products_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'out' where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.date |
select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty | select stock.date_planned, min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty | def init(self, cr): tools.drop_view_if_exists(cr, 'report_delivery_products_planned') cr.execute(""" create or replace view report_delivery_products_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock.picking_id and picking.type = 'out' where stock.date between (select cast(date_trunc('week', current_date) as date)) and (select cast(date_trunc('week', current_date) as date) + 7) group by stock.date |
result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids]) | def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @param field_names: Name of field @return: Dictionary of values """ result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids]) |
|
arch += '<graph string="%s" type="%s" orientation="%s">' % (report.name, report.view_graph_type, report.view_graph_orientation) | orientation_eval = {'horz':'horizontal','vert' :'vertical'} orientation = eval(report.view_graph_orientation,orientation_eval) arch +='<graph string="%s" type="%s" orientation="%s">' % (report.name, report.view_graph_type, orientation) i = 0 | def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Overrides orm field_view_get. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @return: Dictionary of Fields, arch and toolbar. """ if not context: context = {} data = context and context.get('report_id', False) or False if (not context) or 'report_id' not in context: return super(report_creator, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) report = self.browse(cr, user, data) models = {} for model in report.model_ids: models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context) fields = {} i = 0 for f in report.field_ids: if f.field_id.model: fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] i += 1 else: fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} arch = '<?xml version="1.0" encoding="utf-8"?>\n' if view_type == 'graph': arch += '<graph string="%s" type="%s" orientation="%s">' % (report.name, report.view_graph_type, report.view_graph_orientation) for val in ('x','y'): i = 0 for f in report.field_ids: if f.graph_mode == val: if f.field_id.model: arch += '<field name="%s" select="1"/>' % ('field'+str(i),) i += 1 else: arch += '<field name="%s" select="1"/>' % ('column_count',) elif view_type == 'calendar': required_types = ['date_start', 'date_delay', 'color'] set_dict = {'view_type':view_type, 'string':report.name} temp_list = [] i = 0 for f in report.field_ids: if f.calendar_mode and f.calendar_mode in required_types: if f.field_id.model: field_cal = 'field'+str(i) i += 1 else: field_cal = 'column_count' set_dict[f.calendar_mode] = field_cal del required_types[required_types.index(f.calendar_mode)] |
i = 0 | def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Overrides orm field_view_get. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @return: Dictionary of Fields, arch and toolbar. """ if not context: context = {} data = context and context.get('report_id', False) or False if (not context) or 'report_id' not in context: return super(report_creator, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu) report = self.browse(cr, user, data) models = {} for model in report.model_ids: models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context) fields = {} i = 0 for f in report.field_ids: if f.field_id.model: fields['field'+str(i)] = models[f.field_id.model][f.field_id.name] i += 1 else: fields['column_count'] = {'readonly': True, 'type': 'integer', 'string': 'Count', 'size': 64, 'name': 'column_count'} arch = '<?xml version="1.0" encoding="utf-8"?>\n' if view_type == 'graph': arch += '<graph string="%s" type="%s" orientation="%s">' % (report.name, report.view_graph_type, report.view_graph_orientation) for val in ('x','y'): i = 0 for f in report.field_ids: if f.graph_mode == val: if f.field_id.model: arch += '<field name="%s" select="1"/>' % ('field'+str(i),) i += 1 else: arch += '<field name="%s" select="1"/>' % ('column_count',) elif view_type == 'calendar': required_types = ['date_start', 'date_delay', 'color'] set_dict = {'view_type':view_type, 'string':report.name} temp_list = [] i = 0 for f in report.field_ids: if f.calendar_mode and f.calendar_mode in required_types: if f.field_id.model: field_cal = 'field'+str(i) i += 1 else: field_cal = 'column_count' set_dict[f.calendar_mode] = field_cal del required_types[required_types.index(f.calendar_mode)] |
|
groupby.append(t+'.'+f.field_id.name) | def _sql_query_get(self, cr, uid, ids, prop, unknow_none, context, where_plus=[], limit=None, offset=None): """ Get sql query which return on sql_query field. @return: Dictionary of sql query. """ result = {} for obj in self.browse(cr, uid, ids): fields = [] groupby = [] i = 0 for f in obj.field_ids: # Allowing to use count(*) if not f.field_id.model and f.group_method == 'count': fields.insert(0, ('count(*) as column_count')) continue t = self.pool.get(f.field_id.model_id.model)._table if f.group_method == 'group': fields.append('\t'+t+'.'+f.field_id.name+' as field'+str(i)) else: fields.append('\t'+f.group_method+'('+t+'.'+f.field_id.name+')'+' as field'+str(i)) groupby.append(t+'.'+f.field_id.name) i += 1 models = self._path_get(cr, uid, obj.model_ids, obj.filter_ids) check = self._id_get(cr, uid, ids[0], context) if check<>False: fields.insert(0, (check + ' as id')) |
|
def check_date(self, cr, uid, vals, context=None, check=True): | def _check_date(self, cr, uid, vals, context=None, check=True): | def check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} 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['journal_id'] period_id = context['period_id'] journal=self.pool.get('account.journal').browse(cr,uid,[journal_id])[0] if journal.allow_date: period=self.pool.get('account.period').browse(cr,uid,[period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') and time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) else: return True |
period=self.pool.get('account.period').browse(cr,uid,[period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') and time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): | period = self.pool.get('account.period').browse(cr,uid,[period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): | def check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} 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['journal_id'] period_id = context['period_id'] journal=self.pool.get('account.journal').browse(cr,uid,[journal_id])[0] if journal.allow_date: period=self.pool.get('account.period').browse(cr,uid,[period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') and time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'): raise osv.except_osv(_('Error'),_('The date of your Ledger Posting is not in the defined period !')) else: return True |
self.check_date(cr, uid, vals, context, check) | self._check_date(cr, uid, vals, context, check) | def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if not context: context={} if vals.get('account_tax_id', False): raise osv.except_osv(_('Unable to change tax !'), _('You can not change the tax, you should remove and recreate lines !')) self.check_date(cr, uid, vals, context, check) account_obj = self.pool.get('account.account') 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 update_check: if ('account_id' in vals) or ('journal_id' in vals) or ('period_id' in vals) or ('move_id' in vals) or ('debit' in vals) or ('credit' in vals) or ('date' in vals): self._update_check(cr, uid, ids, context) |
self.check_date(cr, uid, vals, context, check) | self._check_date(cr, uid, vals, context, check) | def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if context is None: context = {} self.check_date(cr, uid, vals, context, check) 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 |
statement_id = context.get('statement_id', False) if not statement_id: return {} data = self.read(cr, uid, ids, context=context)[0] line_ids = data['line_ids'] if not line_ids: return {} | def populate_statement(self, cr, uid, ids, context=None): |
|
data = self.read(cr, uid, ids, context=context)[0] line_ids = data['line_ids'] | def populate_statement(self, cr, uid, ids, context=None): |
|
if not line_ids: return {} statement_id = 'statement_id' in context and context['statement_id'] | def populate_statement(self, cr, uid, ids, context=None): |
|
res = mailgate_pool.get_partner(cr, uid, msg.get('from')) | res = mailgate_pool.get_partner(cr, uid, msg.get('from') or msg.get_unixfrom()) | def message_new(self, cr, uid, msg, context): """ Automatically calls when new email message arrives @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks """ |
vals.update({ 'description': msg['body'] }) if msg.get('priority', False): | if msg.get('priority'): | def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}): """ @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 update mail’s IDs """ if isinstance(ids, (str, int, long)): ids = [ids] msg_from = msg['from'] vals.update({ 'description': msg['body'] }) if msg.get('priority', False): vals['priority'] = msg.get('priority') |
if res and maps.get(res.group(1).lower(), False): | if res and maps.get(res.group(1).lower()): | def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}): """ @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 update mail’s IDs """ if isinstance(ids, (str, int, long)): ids = [ids] msg_from = msg['from'] vals.update({ 'description': msg['body'] }) if msg.get('priority', False): vals['priority'] = msg.get('priority') |
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20), | 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20), | def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): move = {} for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): for line in r.line_partial_ids: move[line.move_id.id] = True for line in r.line_id: move[line.move_id.id] = True |
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 50), | 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 50), | def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): move = {} for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): for line in r.line_partial_ids: move[line.move_id.id] = True for line in r.line_id: move[line.move_id.id] = True |
debit = credit = 0.0 context.update({'date':inv.date_invoice}) context_unreconciled=context.copy() | if inv.reconciled: res[inv.id] = 0.0 continue inv_total = inv.amount_total context_unreconciled = context.copy() | def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} if context is None: context = {} |
debit_tmp = lines.debit credit_tmp = lines.credit if inv.company_id.currency_id.id <> inv.currency_id.id: if not inv.reconciled: context.update({'date':lines.date}) context_unreconciled.update({'date':lines.date}) if lines.amount_currency < 0: credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled)) elif lines.amount_currency > 0: debit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.company_id.currency_id.id, lines.amount_currency, round=False, context=context_unreconciled)) debit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, debit_tmp, round=False, context=context) credit += cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id, credit_tmp, round=False, context=context) | if lines.currency_id and lines.currency_id.id == inv.currency_id.id: if inv.type in ('out_invoice','in_refund'): inv_total += lines.amount_currency else: inv_total -= lines.amount_currency | def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} if context is None: context = {} |
debit+=debit_tmp credit+=credit_tmp if not inv.amount_total: result = 0.0 elif inv.type in ('out_invoice','in_refund'): amount = credit-debit result = inv.amount_total - amount else: amount = debit-credit result = inv.amount_total - amount res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_id.currency_id, result) and result or 0.0 | context_unreconciled.update({'date': lines.date}) amount_in_invoice_currency = cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id,abs(lines.debit-lines.credit),round=False,context=context_unreconciled) inv_total -= amount_in_invoice_currency result = inv_total res[inv.id] = self.pool.get('res.currency').round(cr, uid, inv.currency_id, result) | def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} if context is None: context = {} |
res = collection_obj.get_schedule_inbox_URL(cr, uid, ids, context=ctx) | res = dirobj.get_schedule_inbox_URL(cr, uid, ids, context=ctx) | def _get_caldav_schedule_inbox_URL(self, cr): import xml.dom.minidom import urllib dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) ids = [self.dir_id] res = collection_obj.get_schedule_inbox_URL(cr, uid, ids, context=ctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, res))) href.appendChild(huri) return href |
res = collection_obj.get_schedule_outbox_URL(cr, uid, ids, context=ctx) | res = dirobj.get_schedule_outbox_URL(cr, uid, ids, context=ctx) | def _get_caldav_schedule_outbox_URL(self, cr): import xml.dom.minidom import urllib dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) ids = [self.dir_id] res = collection_obj.get_schedule_outbox_URL(cr, uid, ids, context=ctx) doc = xml.dom.minidom.getDOMImplementation().createDocument(None, 'href', None) href = doc.documentElement href.tagName = 'D:href' huri = doc.createTextNode(urllib.quote('/%s/%s' % (cr.dbname, res))) href.appendChild(huri) return href |
launch_date = datetime.now() | launch_date = date | def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return |
launch_date = datetime.now() + transition._delta() | launch_date = date + transition._delta() | def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return |
def action_cancel(self, cr, uid, ids, context=None): res = super(stock_picking, self).action_cancel(cr, uid, ids, context=context) for pick in self.browse(cr, uid, ids, context=context): call_ship_end = True if pick.sale_id: for picks in pick.sale_id.picking_ids: if picks.state not in ('done', 'cancel'): call_ship_end = False break if call_ship_end: self.pool.get('sale.order').action_ship_end(cr, uid, [pick.sale_id.id], context=context) return res | def action_cancel(self, cr, uid, ids, context=None): res = super(stock_picking, self).action_cancel(cr, uid, ids, context=context) for pick in self.browse(cr, uid, ids, context=context): call_ship_end = True if pick.sale_id: for picks in pick.sale_id.picking_ids: if picks.state not in ('done', 'cancel'): call_ship_end = False break if call_ship_end: self.pool.get('sale.order').action_ship_end(cr, uid, [pick.sale_id.id], context=context) return res |
|
'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True), 'phase_id': fields.many2one('project.phase', 'Project Phase', required=True), | 'resource_id': fields.many2one('resource.resource', 'Resource', required=True), 'phase_id': fields.many2one('project.phase', 'Project Phase', ondelete='cascade', required=True), | def set_done(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'done'}) return True |
sub_total[i]= entry.price_subtotal and entry.price_subtotal or 0.00 | sub_total[i]= entry.price_subtotal and entry.price_subtotal | def sale_order_lines(self,sale_order): result =[] sub_total={} info=[] order_lines=[] res={} list_in_seq=[] ids = self.pool.get('sale.order.line').search(self.cr, self.uid, [('order_id', '=', sale_order.id)]) for id in range(0,len(ids)): order = self.pool.get('sale.order.line').browse(self.cr, self.uid,ids[id], self.context.copy()) order_lines.append(order) i=1 j=0 sum_flag={} sum_flag[j]=-1 for entry in order_lines: res={} |
res['note']=entry.notes | res['note']=entry.notes or '' | def sale_order_lines(self,sale_order): result =[] sub_total={} info=[] order_lines=[] res={} list_in_seq=[] ids = self.pool.get('sale.order.line').search(self.cr, self.uid, [('order_id', '=', sale_order.id)]) for id in range(0,len(ids)): order = self.pool.get('sale.order.line').browse(self.cr, self.uid,ids[id], self.context.copy()) order_lines.append(order) i=1 j=0 sum_flag={} sum_flag[j]=-1 for entry in order_lines: res={} |
def _get_new_period_start(self,cr,uid,context={}): | def _get_new_period_start(self, cr, uid, context=None): | def _get_new_period_start(self,cr,uid,context={}): cr.execute("select max(date_stop) from stock_period") result=cr.fetchone() last_date = result and result[0] or False if last_date: period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1) period_start = period_start - RelativeDateTime(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second) else: period_start = mx.DateTime.today() return period_start.strftime('%Y-%m-%d') |
def create_period_weekly(self,cr, uid, ids, context={}): res=self.create_period(cr, uid, ids, context, 6, 'Weekly') | def create_period_weekly(self, cr, uid, ids, context=None): res = self.create_period(cr, uid, ids, context, 6, 'Weekly') | def _get_new_period_start(self,cr,uid,context={}): cr.execute("select max(date_stop) from stock_period") result=cr.fetchone() last_date = result and result[0] or False if last_date: period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1) period_start = period_start - RelativeDateTime(hours=period_start.hour, minutes=period_start.minute, seconds=period_start.second) else: period_start = mx.DateTime.today() return period_start.strftime('%Y-%m-%d') |
def create_period_monthly(self,cr, uid, ids, context={},interval=1): for p in self.browse(cr, uid, ids, context): | def create_period_monthly(self,cr, uid, ids, interval=1, context=None): for p in self.browse(cr, uid, ids, context=context): | def create_period_weekly(self,cr, uid, ids, context={}): res=self.create_period(cr, uid, ids, context, 6, 'Weekly') return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', } |
'type': 'ir.actions.act_window', } def create_period(self,cr, uid, ids, context={}, interval=0, name='Daily'): for p in self.browse(cr, uid, ids, context): | 'type': 'ir.actions.act_window', } def create_period(self, cr, uid, ids, interval=0, name='Daily', context=None): for p in self.browse(cr, uid, ids, context=context): | def create_period_monthly(self,cr, uid, ids, context={},interval=1): for p in self.browse(cr, uid, ids, context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')<p.date_stop: de = ds + RelativeDateTime(months=interval, minutes=-1) self.pool.get('stock.period').create(cr, uid, { 'name': ds.strftime('%Y/%m'), 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + RelativeDateTime(months=interval) return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', } |
'name': fields.char('Period Name', size=64), | 'name': fields.char('Period Name', size=64, required=True), | def create_period(self,cr, uid, ids, context={}, interval=0, name='Daily'): for p in self.browse(cr, uid, ids, context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')<p.date_stop: de = ds + RelativeDateTime(days=interval, minutes =-1) if name=='Daily': new_name=de.strftime('%Y-%m-%d') if name=="Weekly": new_name=de.strftime('%Y, week %W') self.pool.get('stock.period').create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + RelativeDateTime(days=interval) + 1 return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', } |
'state' : lambda * a : 'draft' | 'state': 'draft' | def create_period(self,cr, uid, ids, context={}, interval=0, name='Daily'): for p in self.browse(cr, uid, ids, context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')<p.date_stop: de = ds + RelativeDateTime(days=interval, minutes =-1) if name=='Daily': new_name=de.strftime('%Y-%m-%d') if name=="Weekly": new_name=de.strftime('%Y, week %W') self.pool.get('stock.period').create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + RelativeDateTime(days=interval) + 1 return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', } |
'copy_forecast' : fields.boolean('Copy Last Forecast', help="Copy quantities from last Stock and Sale Forecast."), | 'copy_forecast': fields.boolean('Copy Last Forecast', help="Copy quantities from last Stock and Sale Forecast."), } _defaults = { 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.sale.forecast.createlines', context=c), | # def _get_latest_period(self,cr,uid,context={}): |
_defaults = { 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.sale.forecast.createlines', context=c), } def create_forecast(self,cr, uid, ids, context={}): | def create_forecast(self, cr, uid, ids, context=None): | # def _get_latest_period(self,cr,uid,context={}): |
forecast_obj=self.pool.get('stock.sale.forecast') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context): prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.template') | forecast_obj = self.pool.get('stock.sale.forecast') mod_obj = self.pool.get('ir.model.data') prod_categ_obj = self.pool.get('product.category') template_obj = self.pool.get('product.template') for f in self.browse(cr, uid, ids, context=context): | def create_forecast(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') forecast_obj=self.pool.get('stock.sale.forecast') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context): prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.template') categ_ids = f.product_categ_id1.id and [f.product_categ_id1.id] or [] prod_categ_ids=prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_ids = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_ids)==0: raise osv.except_osv(_('Error !'), _('No products in selected category !')) copy = f.copy_forecast for p in product_obj.browse(cr, uid, products_ids,{}): if len(forecast_obj.search(cr, uid, [('product_id','=',p.id) , \ ('period_id','=',f.period_id1.id), \ ('user_id','=',uid), \ ('warehouse_id','=',f.warehouse_id1.id)]))== 0: forecast_qty = 0.0 |
'state': lambda *args: 'draft', | 'state': 'draft', | def create_forecast(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') forecast_obj=self.pool.get('stock.sale.forecast') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context): prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.template') categ_ids = f.product_categ_id1.id and [f.product_categ_id1.id] or [] prod_categ_ids=prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_ids = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_ids)==0: raise osv.except_osv(_('Error !'), _('No products in selected category !')) copy = f.copy_forecast for p in product_obj.browse(cr, uid, products_ids,{}): if len(forecast_obj.search(cr, uid, [('product_id','=',p.id) , \ ('period_id','=',f.period_id1.id), \ ('user_id','=',uid), \ ('warehouse_id','=',f.warehouse_id1.id)]))== 0: forecast_qty = 0.0 |
def unlink(self, cr, uid, ids, context={}): | def unlink(self, cr, uid, ids, context=None): | def action_validate(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'validated','user_id':uid}) return True |
def onchange_company(self, cr, uid, ids, company_id): | def onchange_company(self, cr, uid, ids, company_id=False): | def onchange_company(self, cr, uid, ids, company_id): result = {} if company_id: result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False return {'value': result} |
if company_id: result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False | if not company_id: return result result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False | def onchange_company(self, cr, uid, ids, company_id): result = {} if company_id: result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False return {'value': result} |
def product_id_change(self, cr, uid, ids, product_id): ret={} | def product_id_change(self, cr, uid, ids, product_id=False): ret = {} | def product_id_change(self, cr, uid, ids, product_id): ret={} if product_id: product_rec = self.pool.get('product.product').browse(cr, uid, product_id) ret['product_uom'] = product_rec.uom_id.id ret['product_uom_categ'] = product_rec.uom_id.category_id.id ret['product_uos_categ'] = product_rec.uos_id and product_rec.uos_id.category_id.id or False ret['active_uom'] = product_rec.uom_id.id else: ret['product_uom'] = False ret['product_uom_categ'] = False ret['product_uos_categ'] = False res = {'value': ret} return res |
def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, active_uom=False ): ret={} val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, active_uom, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['product_qty'] = rounding(coeff * product_qty, round_value) ret['active_uom'] = product_uom | def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, active_uom=False): ret = {} if not ids: return {} if product_uom: val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, active_uom, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['product_qty'] = rounding(coeff * product_qty, round_value) ret['active_uom'] = product_uom | def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, active_uom=False ): ret={} val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, active_uom, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['product_qty'] = rounding(coeff * product_qty, round_value) ret['active_uom'] = product_uom return {'value': ret} |
ret={} | ret = {} if not ids: return {} | def product_amt_change(self, cr, uid, ids, product_amt = 0.0, product_uom=False): ret={} round_value = 1 if product_amt: coeff_def2uom = 1 val1 = self.browse(cr, uid, ids) val = val1[0] if (product_uom != val.product_id.uom_id.id): coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) ret['product_qty'] = rounding(coeff_def2uom * product_amt/(val.product_id.product_tmpl_id.list_price), round_value) res = {'value': ret} return res |
def _to_default_uom_factor(self, cr, uid, val, uom_id, context): | def _to_default_uom_factor(self, cr, uid, val, uom_id, context=None): | def _to_default_uom_factor(self, cr, uid, val, uom_id, context): uom_obj = self.pool.get('product.uom') uom = uom_obj.browse(cr, uid, uom_id, context=context) coef = uom.factor if uom.category_id.id <> val.product_id.uom_id.category_id.id: coef = coef / val.product_id.uos_coeff return val.product_id.uom_id.factor / coef |
def _sales_per_company(self, cr, uid, so, so_line, company, ): | def _sales_per_company(self, cr, uid, so, so_line, company): | def _sales_per_company(self, cr, uid, so, so_line, company, ): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(so), company)) ret = cr.fetchone()[0] or 0.0 return ret |
"WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(so), company)) | "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)", (tuple(so_line), tuple(so), company)) | def _sales_per_company(self, cr, uid, so, so_line, company, ): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(so), company)) ret = cr.fetchone()[0] or 0.0 return ret |
def onchange_company(self, cr, uid, ids, company_id): | def onchange_company(self, cr, uid, ids, company_id=False): | def onchange_company(self, cr, uid, ids, company_id): result = {} if company_id: result['warehouse_id2'] = False return {'value': result} |
def create_planning(self,cr, uid, ids, context={}): | def create_planning(self,cr, uid, ids, context=None): if context is None: context = {} | def create_planning(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') planning_obj=self.pool.get('stock.planning') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast \ WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id)) products_id1 = [x for x, in cr.fetchall()] else: prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.template') categ_ids = f.product_categ_id2.id and [f.product_categ_id2.id] or [] prod_categ_ids=prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_id1)==0: raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !')) |
def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context): | def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context=None): | def create_planning(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') planning_obj=self.pool.get('stock.planning') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast \ WHERE (period_id = %s) AND (warehouse_id = %s)", (f.period_id2.id, f.warehouse_id2.id)) products_id1 = [x for x, in cr.fetchall()] else: prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.template') categ_ids = f.product_categ_id2.id and [f.product_categ_id2.id] or [] prod_categ_ids=prod_categ_obj.search(cr,uid,[('parent_id','child_of',categ_ids)]) templates_ids = template_obj.search(cr,uid,[('categ_id','in',prod_categ_ids)]) products_id1 = product_obj.search(cr,uid,[('product_tmpl_id','in',templates_ids)]) if len(products_id1)==0: raise osv.except_osv(_('Error !'), _('No forecasts for selected period or no products in selected category !')) |
if not context: context = {} product_obj = self.pool.get('product.product') | def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context): |
|
product_obj = self.pool.get('product.product') | def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context): |
|
def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context): | def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context=None): | def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context): cr.execute("SELECT sum(planning.planned_outgoing), planning.product_uom \ FROM stock_planning AS planning \ LEFT JOIN stock_period AS period \ ON (planning.period_id = period.id) \ WHERE (period.date_stop >= %s) AND (period.date_stop <= %s) \ AND (planning.product_id = %s) AND (planning.company_id = %s) \ GROUP BY planning.product_uom", \ (date_start, date_stop, val.product_id.id, val.company_id.id,)) planning_qtys = cr.fetchall() res = self._to_planning_uom(cr, uid, val, planning_qtys, context) return res |
def _get_forecast(self, cr, uid, ids, field_names, arg, context): | def _get_forecast(self, cr, uid, ids, field_names, arg, context=None): | def _to_planning_uom(self, cr, uid, val, qtys, context): res_qty = 0 if qtys: uom_obj = self.pool.get('product.uom') for qty, prod_uom in qtys: coef = self._to_default_uom_factor(cr, uid, val, prod_uom, context=context) res_coef, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=context) coef = coef * res_coef res_qty += rounding(qty * coef, round_value) return res_qty |
def _get_stock_start(self, cr, uid, val, date, context): | def _get_stock_start(self, cr, uid, val, date, context=None): | def _get_stock_start(self, cr, uid, val, date, context): context['from_date'] = None context['to_date'] = date locations = [val.warehouse_id.lot_stock_id.id,] if not val.stock_only: locations.extend([val.warehouse_id.lot_input_id.id, val.warehouse_id.lot_output_id.id]) context['location'] = locations context['compute_child'] = True product_obj = self.pool.get('product.product').read(cr, uid,val.product_id.id,[], context) res = product_obj['qty_available'] # value for stock_start return res |
def _get_op(self, cr, uid, ids, field_names, arg, context): | def _get_op(self, cr, uid, ids, field_names, arg, context=None): | def _get_op(self, cr, uid, ids, field_names, arg, context): # op = OrderPoint res = {} for val in self.browse(cr, uid, ids, context=context): res[val.id]={} cr.execute("SELECT product_min_qty, product_max_qty, product_uom \ FROM stock_warehouse_orderpoint \ WHERE warehouse_id = %s AND product_id = %s AND active = 'TRUE'", (val.warehouse_id.id, val.product_id.id)) ret = cr.fetchone() or [0.0,0.0,False] coef = 1 round_value = 1 if ret[2]: coef = self._to_default_uom_factor(cr, uid, val, ret[2], context) res_coef, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=context) coef = coef * res_coef res[val.id]['minimum_op'] = rounding(ret[0]*coef, round_value) res[val.id]['maximum_op'] = ret[1]*coef return res |
def onchange_company(self, cr, uid, ids, company_id): | def onchange_company(self, cr, uid, ids, company_id=False): | def _get_op(self, cr, uid, ids, field_names, arg, context): # op = OrderPoint res = {} for val in self.browse(cr, uid, ids, context=context): res[val.id]={} cr.execute("SELECT product_min_qty, product_max_qty, product_uom \ FROM stock_warehouse_orderpoint \ WHERE warehouse_id = %s AND product_id = %s AND active = 'TRUE'", (val.warehouse_id.id, val.product_id.id)) ret = cr.fetchone() or [0.0,0.0,False] coef = 1 round_value = 1 if ret[2]: coef = self._to_default_uom_factor(cr, uid, val, ret[2], context) res_coef, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=context) coef = coef * res_coef res[val.id]['minimum_op'] = rounding(ret[0]*coef, round_value) res[val.id]['maximum_op'] = ret[1]*coef return res |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.