rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
sum(-m.product_qty*u.factor)::decimal as product_qty, sum(-pt.standard_price * m.product_qty * u.factor)::decimal as value from | coalesce(sum(-m.product_qty * u.factor)::decimal, 0.0) as product_qty, coalesce(sum(-pt.standard_price * m.product_qty * u.factor)::decimal, 0.0) as value FROM | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_inventory') cr.execute(""" |
left join stock_picking p on (m.picking_id=p.id) left join product_product pp on (m.product_id=pp.id) left join product_template pt on (pp.product_tmpl_id=pt.id) left join product_uom u on (m.product_uom=u.id) left join stock_location l on (m.location_id=l.id) group by | LEFT JOIN stock_picking p ON (m.picking_id=p.id) LEFT JOIN product_product pp ON (m.product_id=pp.id) LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) LEFT JOIN product_uom u ON (m.product_uom=u.id) LEFT JOIN stock_location l ON (m.location_id=l.id) GROUP BY | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_inventory') cr.execute(""" |
) union all ( select | ) UNION ALL ( SELECT | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_inventory') cr.execute(""" |
sum(m.product_qty*u.factor)::decimal as product_qty, sum(pt.standard_price * m.product_qty * u.factor)::decimal as value from | coalesce(sum(m.product_qty*u.factor)::decimal, 0.0) as product_qty, coalesce(sum(pt.standard_price * m.product_qty * u.factor)::decimal, 0.0) as value FROM | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_inventory') cr.execute(""" |
left join stock_picking p on (m.picking_id=p.id) left join product_product pp on (m.product_id=pp.id) left join product_template pt on (pp.product_tmpl_id=pt.id) left join product_uom u on (m.product_uom=u.id) left join stock_location l on (m.location_dest_id=l.id) group by | LEFT JOIN stock_picking p ON (m.picking_id=p.id) LEFT JOIN product_product pp ON (m.product_id=pp.id) LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) LEFT JOIN product_uom u ON (m.product_uom=u.id) LEFT JOIN stock_location l ON (m.location_dest_id=l.id) GROUP BY | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_inventory') cr.execute(""" |
periods = [x[0] for x in data['form']['periods'][1]] data['form']['periods'] = periods | periods = data['form']['periods'] | def _print_report(self, cr, uid, ids, data, query_line, context=None): periods = [x[0] for x in data['form']['periods'][1]] data['form']['periods'] = periods data['ids'] = ids obj_jperiod = self.pool.get('account.journal.period') if isinstance(periods, list): ids_final = [] for journal in data['form']['journal_ids']: for period in periods: ids_journal_period = obj_jperiod.search(cr,uid, [('journal_id','=',journal),('period_id','=',period)], context=context) if ids_journal_period: ids_final.append(ids_journal_period) if not ids_final: raise osv.except_osv(_('No Data Available'), _('No records found for your selection!')) return { 'type': 'ir.actions.report.xml', 'report_name': 'account.central.journal.wiz', 'datas': data, 'nodestroy':True, } |
ctx['date'] = line.ml_maturity_date | if data['form']['date_select'] == 'date_maturity': date_line = line.ml_maturity_date ctx['date'] = date_line | def _populate_statement(obj, cursor, user, data, context): line_ids = data['form']['lines'][0][2] if not line_ids: return {} pool = pooler.get_pool(cursor.dbname) line_obj = pool.get('payment.line') statement_obj = pool.get('account.bank.statement') statement_line_obj = pool.get('account.bank.statement.line') currency_obj = pool.get('res.currency') statement_reconcile_obj = pool.get('account.bank.statement.reconcile') statement = statement_obj.browse(cursor, user, data['id'], context=context) for line in line_obj.browse(cursor, user, line_ids, context=context): ctx = context.copy() ctx['date'] = line.ml_maturity_date # was value_date earlier,but this field exists no more now amount = currency_obj.compute(cursor, user, line.currency.id, statement.currency.id, line.amount_currency, context=ctx) if line.move_line_id: reconcile_id = statement_reconcile_obj.create(cursor, user, { 'line_ids': [(6, 0, [line.move_line_id.id])] }, context=context) statement_line_obj.create(cursor, user, { 'name': line.order_id.reference or '?', 'amount': - amount, 'type': 'supplier', 'partner_id': line.partner_id.id, 'account_id': line.move_line_id.account_id.id, 'statement_id': statement.id, 'ref': line.communication, 'reconcile_id': reconcile_id, }, context=context) return {} |
if to_update[id]['partner_id'] in data['partner_ids'][0][2]: | if to_update[id]['partner_id'] in data['partner_ids']: | def do_print(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids, [])[0] res = self._get_partners_followp(cr, uid, ids, context)['to_update'] to_update = res data['followup_id'] = 'followup_id' in context and context['followup_id'] or False date = 'date' in context and context['date'] or data['date'] for id in to_update.keys(): if to_update[id]['partner_id'] in data['partner_ids'][0][2]: cr.execute( "UPDATE account_move_line "\ "SET followup_line_id=%s, followup_date=%s "\ "WHERE id=%s", (to_update[id]['level'], date, int(id),)) |
singer_statement() | account_cashbox_line() | def on_change_sub(self, cr, uid, ids, pieces, number,*a): |
'balance_start': fields.function(_get_starting_balance, method=True, string='Opening Balance', type='float',digits=(16,2), help="Opening balance based on cashBox"), | 'balance_start': fields.function(_get_starting_balance, store=True, method=True, string='Opening Balance', type='float',digits=(16,2), help="Opening balance based on cashBox"), | def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') |
'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, string="Cash Transaction", help="Total cash transactions"), | 'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, store=True, string="Cash Transaction", help="Total cash transactions"), | def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') |
'balance_end': fields.function(_end_balance, method=True, string='Balance', help="Closing balance based on transactions"), 'balance_end_cash': fields.function(_balance_end_cash, method=True, string='Balance', help="Closing balance based on cashBox"), 'starting_details_ids': fields.one2many('singer.statement', 'starting_id', string='Opening Cashbox'), 'ending_details_ids': fields.one2many('singer.statement', 'ending_id', string='Closing Cashbox'), | 'balance_end': fields.function(_end_balance, method=True, store=True, string='Balance', help="Closing balance based on transactions"), 'balance_end_cash': fields.function(_balance_end_cash, method=True, store=True, string='Balance', help="Closing balance based on cashBox"), 'starting_details_ids': fields.one2many('account.cashbox.line', 'starting_id', string='Opening Cashbox'), 'ending_details_ids': fields.one2many('account.cashbox.line', 'ending_id', string='Closing Cashbox'), | def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') |
'user_id': lambda self, cr, uid, context=None: uid | 'user_id': lambda self, cr, uid, context=None: uid, 'company_id': _get_company | def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') |
cash_pool = self.pool.get('singer.statement') | cash_pool = self.pool.get('account.cashbox.line') | def onchange_journal_id(self, cr, uid, statement_id, journal_id, context={}): """ Changes balance start and starting details if journal_id changes" @param statement_id: Changed statement_id @param journal_id: Changed journal_id @return: Dictionary of changed values """ cash_pool = self.pool.get('singer.statement') statement_pool = self.pool.get('account.bank.statement') |
cash_pool = self.pool.get('singer.statement') | cash_pool = self.pool.get('account.cashbox.line') | def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ cash_pool = self.pool.get('singer.statement') statement_pool = self.pool.get('account.bank.statement') |
action_id = mod_obj._get_id(cr, uid, 'wiki', 'action_view_wiki_wiki_page_open') action_id = mod_obj.copy(cr, uid, action_id, context=context, default={ 'domain':"[('group_id','=',"+str(context.get('active_id',False))+"]", "name": menu.menu_name }) | for menu in self.browse(cr, uid, ids): action_id = mod_obj._get_id(cr, uid, 'wiki', 'action_view_wiki_wiki_page_open') action_id = mod_obj.copy(cr, uid, action_id, context=context, default={ 'domain':"[('group_id','=',"+str(context.get('active_id',False))+"]", "name": menu.menu_name }) | def wiki_menu_create(self, cr, uid, ids, context): |
for menu in self.browse(cr, uid, ids): | def wiki_menu_create(self, cr, uid, ids, context): |
|
print 'Created menu', menu_id, action_id | def wiki_menu_create(self, cr, uid, ids, context): |
|
if not (obj.amount == obj.voucher_id.amount): | if not (abs(obj.amount) == obj.voucher_id.amount): | def _check_amount(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): if obj.voucher_id: if not (obj.amount == obj.voucher_id.amount): return False return True |
@param name: @param arg: | @param name: name of the field @param arg: user defined argument | def _child_compute(self, cr, uid, ids, name, arg, context={}): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID of mrp.production object @param name: @param arg: |
print "name",name print "arg",arg print "result",result | def _child_compute(self, cr, uid, ids, name, arg, context={}): """ @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID of mrp.production object @param name: @param arg: |
|
def _get_effective_date(self, cr, uid, ids, name, arg, context={}): | def _get_effective_date(self, cr, uid, ids, name, arg, context=None): | def _get_effective_date(self, cr, uid, ids, name, arg, context={}): res = {} dates_list = [] for order in self.browse(cr, uid, ids): dates_list = [] for pick in order.picking_ids: dates_list.append(pick.date) if dates_list: res[order.id] = min(dates_list) else: res[order.id] = False return res |
def _get_commitment_date(self, cr, uid, ids, name, arg, context={}): | def _get_commitment_date(self, cr, uid, ids, name, arg, context=None): | def _get_commitment_date(self, cr, uid, ids, name, arg, context={}): res = {} dates_list = [] for order in self.browse(cr, uid, ids): dates_list = [] for line in order.order_line: dt = datetime.strptime(order.date_order, '%Y-%m-%d') + relativedelta(days=line.delay or 0.0) dt_s = dt.strftime('%Y-%m-%d') dates_list.append(dt_s) if dates_list: res[order.id] = min(dates_list) return res |
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) | sale_order_line l ,product_uom u, product_product p, product_template pt where u.id = l.product_uom and pt.id = p.product_tmpl_id and p.id = l.product_id | 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, 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.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 ) """) |
for (id, name) in product_obj.name_get(cr, uid, [move.product_id.id]): message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(move.product_qty) + "' "+ _("quantity.") self.log(cr, uid, move.id, message) | for new_move in self.browse(cr, uid, res, context=context): for (id, name) in product_obj.name_get(cr, uid, [new_move.product_id.id]): message = _('Product ') + " '" + name + "' "+ _("is consumed with") + " '" + str(new_move.product_qty) + "' "+ _("quantity.") self.log(cr, uid, new_move.id, message) | def action_consume(self, cr, uid, ids, quantity, location_id=False, context=None): """ Consumed product with specific quatity from specific source location @param cr: the database cursor @param uid: the user id @param ids: ids of stock move object to be consumed @param quantity : specify consume quantity @param location_id : specify source location @param context: context arguments @return: Consumed lines """ if context is None: context = {} if quantity <= 0: raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !')) |
'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_rel', 'order_id', 'invoice_id', 'Invoices', help="This is the list of invoices that have been generated for this sale order. The same sale order may have been invoiced in several times (by line for example)."), | 'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_rel', 'order_id', 'invoice_id', 'Invoices', readonly=True, help="This is the list of invoices that have been generated for this sale order. The same sale order may have been invoiced in several times (by line for example)."), | def _get_order(self, cr, uid, ids, context=None): if context is None: context = {} result = {} for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): result[line.order_id.id] = True return result.keys() |
def _model_search(self, cr, uid, obj, name, args): | def _model_search(self, cr, uid, obj, name, args, context={}): | def _model_search(self, cr, uid, obj, name, args): if not len(args): return [] model_id= args[0][2] if not model_id: return [] model = self.pool.get('ir.model').read(cr,uid,[model_id])[0]['model'] report_id = self.search(cr,uid,[('model','=',model)]) if not report_id: return [('id','=','0')] return [('id','in',report_id)] |
if not context: | if context is None: | def write(self, cr, uid, ids, vals, context=None): if not context: context = {} if 'active' in vals and not vals['active']: self._check_moves(cr, uid, ids, "write", context) return super(account_account, self).write(cr, uid, ids, vals, context=context) |
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty) | taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty) | def _amount_line(self, cr, uid, ids, field_name, arg, context=None): tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') res = {} context = context or {} for line in self.browse(cr, uid, ids, context=context): price = line.price_unit * line.product_uom_qty * (1 - (line.discount or 0.0) / 100.0) taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty) cur = line.order_id.pricelist_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, taxes['total']) return res |
if line.credit and line.reconcile_partial_id: | if line.credit and line.reconcile_partial_id and ttype == 'receipt': continue if line.debit and line.reconcile_partial_id and ttype == 'payment': | def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ if not journal_id: return {} currency_pool = self.pool.get('res.currency') move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') default = { 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False}, } |
if line.credit and line.reconcile_partial_id: | if line.credit and line.reconcile_partial_id and ttype == 'receipt': | def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ if not journal_id: return {} currency_pool = self.pool.get('res.currency') move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') default = { 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False}, } |
if inv.journal_id.type in ('sale','sale_refund', 'cash', 'bank'): | if inv.type in ('sale', 'receipt'): | def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False |
def unlink(self, cr, uid, ids, context={}): | def unlink(self, cr, uid, ids, context=None): | def unlink(self, cr, uid, ids, context={}): vouchers = self.read(cr, uid, ids, ['state']) unlink_ids = [] for t in vouchers: if t['state'] in ('draft', 'cancel'): unlink_ids.append(t['id']) else: raise osv.except_osv('Invalid action !', 'Cannot delete Voucher(s) which are already opened or paid !') return super(account_voucher, self).unlink(self, cr, uid, unlink_ids) |
return super(account_voucher, self).unlink(self, cr, uid, unlink_ids) | return super(account_voucher, self).unlink(cr, uid, unlink_ids, context=context) | def unlink(self, cr, uid, ids, context={}): vouchers = self.read(cr, uid, ids, ['state']) unlink_ids = [] for t in vouchers: if t['state'] in ('draft', 'cancel'): unlink_ids.append(t['id']) else: raise osv.except_osv('Invalid action !', 'Cannot delete Voucher(s) which are already opened or paid !') return super(account_voucher, self).unlink(self, cr, uid, unlink_ids) |
start_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S") | def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """ @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 base_start_date: Get Start Date @param base_until_date: Get End Date @param limit: The Number of Results to Return """ |
|
phase_resource = False | def generate_schedule(self, cr, uid, ids, start_date, calendar_id=False, context=None): """ Schedule phase with the start date till all the next phases are completed. @param: start_dsate : start date for the phase @param: calendar_id : working calendar of the project """ if context is None: context = {} resource_pool = self.pool.get('resource.resource') uom_pool = self.pool.get('product.uom') phase_resource = False if context is None: context = {} default_uom_id = self._get_default_uom_id(cr, uid) for phase in self.browse(cr, uid, ids, context=context): if not phase.responsible_id: raise osv.except_osv(_('No responsible person assigned !'),_("You must assign a responsible person for phase '%s' !") % (phase.name,)) phase_resource_obj = resource_pool.generate_resources(cr, uid, [phase.responsible_id.id], calendar_id, context=context) avg_hours = uom_pool._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id) duration = str(avg_hours) + 'H' # Create a new project for each phase def Project(): start = start_date minimum_time_unit = 1 resource = phase_resource_obj # If project has working calendar then that # else the default one would be considered if calendar_id: working_days = resource_pool.compute_working_calendar(cr, uid, calendar_id, context=context) vacation = tuple(resource_pool.compute_vacation(cr, uid, calendar_id)) |
|
start = start_date minimum_time_unit = 1 resource = phase_resource_obj | def Project(): start = start_date minimum_time_unit = 1 resource = phase_resource_obj # If project has working calendar then that # else the default one would be considered if calendar_id: working_days = resource_pool.compute_working_calendar(cr, uid, calendar_id, context=context) vacation = tuple(resource_pool.compute_vacation(cr, uid, calendar_id)) |
|
number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id=%s', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id}) | number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id}) | def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: if obj_inv.journal_id.invoice_sequence_id: sid = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id=%s', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id}) else: number = self.pool.get('ir.sequence').get(cr, uid, 'account.invoice.' + invtype) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True |
result = ids | result = [] | def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if isinstance(select, (str, int, long)): ids = [select] else: ids = select result = ids if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") |
clean() | def execute(connector, method, *args): global wait_count res = False try: res = getattr(connector,method)(*args) except socket.error,e: if e.args[0] == 111: if wait_count > wait_limit: print "Server is taking too long to start, it has exceeded the maximum limit of %d seconds."%(wait_limit) clean() sys.exit(1) print 'Please wait %d sec to start server....'%(waittime) wait_count += 1 time.sleep(waittime) res = execute(connector, method, *args) else: return res wait_count = 0 return res |
|
def check_creds(db, uid, passwd): if security._uid_cache.get(db, {}).get(uid) and security._uid_cache.get(db, {}).get(uid) == passwd: | def check(db, uid, passwd): cached_pass = security._uid_cache.get(db, {}).get(uid) if (cached_pass is not None) and cached_pass == passwd: | def check_creds(db, uid, passwd): if security._uid_cache.get(db, {}).get(uid) and security._uid_cache.get(db, {}).get(uid) == passwd: return True cr = pooler.get_db(db).cursor() if passwd not in _salt_cache: cr.execute( 'select login from res_users where id=%s', (uid,) ) stored_login = cr.fetchone() if stored_login: stored_login = stored_login[0] if not login(db,stored_login,passwd): return False salt = _salt_cache[passwd] cr.execute(' select count(*) from res_users where id=%s and password=%s', (int(uid), encrypt_md5( passwd, salt )) ) res = cr.fetchone()[0] cr.close() if not bool(res): raise security.ExceptionNoTb('AccessDenied') if res: security._uid_cache[uid] = passwd return bool(res) |
return False | return security.ExceptionNoTb('AccessDenied') | def check_creds(db, uid, passwd): if security._uid_cache.get(db, {}).get(uid) and security._uid_cache.get(db, {}).get(uid) == passwd: return True cr = pooler.get_db(db).cursor() if passwd not in _salt_cache: cr.execute( 'select login from res_users where id=%s', (uid,) ) stored_login = cr.fetchone() if stored_login: stored_login = stored_login[0] if not login(db,stored_login,passwd): return False salt = _salt_cache[passwd] cr.execute(' select count(*) from res_users where id=%s and password=%s', (int(uid), encrypt_md5( passwd, salt )) ) res = cr.fetchone()[0] cr.close() if not bool(res): raise security.ExceptionNoTb('AccessDenied') if res: security._uid_cache[uid] = passwd return bool(res) |
security.check_creds=check_creds | security.check=check | def access(db, uid, passwd, sec_level, ids): cr = pooler.get_db(db).cursor() salt = _salt_cache[passwd] cr.execute('select id from res_users where id=%s and password=%s', (uid, encrypt_md5( passwd, salt )) ) res = cr.fetchone() cr.close() if not res: raise security.ExceptionNoTb('Bad username or password') return res[0] |
invoice_domain.append(('id', '=', created_inv)) | invoice_domain.append(('id', 'in', created_inv)) | def compute_refund(self, cr, uid, ids, mode='refund', context=None): """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: the account invoice refund’s ID or list of IDs |
domain = [('object_id.model', '=', model)] | domain = [('object_id.model', '=', model),('section_ids', '=', case.section_id.id)] | def stage_next(self, cr, uid, ids, context=None): """This function computes next stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') model = self._name for case in self.browse(cr, uid, ids, context): next_stage = False data = {} domain = [('object_id.model', '=', model)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = -1 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index + 1 == len(stages): return False else: next_stage = stages[index + 1] if next_stage: data = {'stage_id': next_stage} stage = stage_pool.browse(cr, uid, next_stage, context=context) if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return next_stage |
domain = [('object_id.model', '=', model)] | domain = [('object_id.model', '=', model),('section_ids', '=', case.section_id.id)] | def stage_previous(self, cr, uid, ids, context=None): """This function computes previous stage for case from its current stage using available stage for that case type @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case IDs @param context: A standard dictionary for contextual values""" if not context: context = {} stage_pool = self.pool.get('crm.case.stage') model = self._name for case in self.browse(cr, uid, ids, context): prev_stage = False data = {} domain = [('object_id.model', '=', model)] if case.section_id and case.section_id.stage_ids: domain.append(('id', 'in', map(lambda x: x.id, case.section_id.stage_ids))) stages = stage_pool.search(cr, uid, domain, order='sequence') index = 0 if case.stage_id and case.stage_id.id in stages: index = stages.index(case.stage_id.id) if index == 0: return False else: prev_stage = stages[index - 1] if prev_stage: data = {'stage_id': prev_stage} stage = stage_pool.browse(cr, uid, prev_stage, context=context) if stage.on_change: data.update({'probability': stage.probability}) self.write(cr, uid, [case.id], data, context=context) return prev_stage |
number = self.pool.get('ir.sequence').get(cr, uid, 'account.bank.statement') | number = self.pool.get('ir.sequence').get(cr, uid, statement.journal_id.sequence_id.code) | def button_open(self, cr, uid, ids, context=None): """ Changes statement state to Running. @return: True """ cash_pool = self.pool.get('account.cashbox.line') statement_pool = self.pool.get('account.bank.statement') |
'keep_if_condition_not_met': fields.boolean('Keep as cancelled', | 'keep_if_condition_not_met': fields.boolean("Don't delete workitems", | def process_segment(self, cr, uid, segment_ids=None, context=None): Workitems = self.pool.get('marketing.campaign.workitem') if not segment_ids: segment_ids = self.search(cr, uid, [('state', '=', 'running')], context=context) |
for line in self.browse(cr, uid, ids): | for line in self.browse(cr, uid, ids, context=context): | def _state(self, cr, uid, ids, name, args, context=None): """Compute the state lines @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 Membership Line IDs @param name: Field Name @param context: A standard dictionary for contextual values @param return: Dictionary of state Value """ res = {} for line in self.browse(cr, uid, ids): cr.execute(''' SELECT i.state, i.id FROM account_invoice i WHERE i.id = ( SELECT l.invoice_id FROM account_invoice_line l WHERE l.id = ( SELECT ml.account_invoice_line FROM membership_membership_line ml WHERE ml.id = %s ) ) ''', (line.id,)) fetched = cr.fetchone() if not fetched : res[line.id] = 'canceled' continue istate = fetched[0] state = 'none' if (istate == 'draft') | (istate == 'proforma'): state = 'waiting' elif istate == 'open': state = 'invoiced' elif istate == 'paid': state = 'paid' inv = self.pool.get('account.invoice').browse(cr, uid, fetched[1]) for payment in inv.payment_ids: if payment.invoice and payment.invoice.type == 'out_refund': state = 'canceled' elif istate == 'cancel': state = 'canceled' res[line.id] = state return res |
inv = self.pool.get('account.invoice').browse(cr, uid, fetched[1]) | inv = self.pool.get('account.invoice').browse(cr, uid, fetched[1], context=context) | def _state(self, cr, uid, ids, name, args, context=None): """Compute the state lines @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 Membership Line IDs @param name: Field Name @param context: A standard dictionary for contextual values @param return: Dictionary of state Value """ res = {} for line in self.browse(cr, uid, ids): cr.execute(''' SELECT i.state, i.id FROM account_invoice i WHERE i.id = ( SELECT l.invoice_id FROM account_invoice_line l WHERE l.id = ( SELECT ml.account_invoice_line FROM membership_membership_line ml WHERE ml.id = %s ) ) ''', (line.id,)) fetched = cr.fetchone() if not fetched : res[line.id] = 'canceled' continue istate = fetched[0] state = 'none' if (istate == 'draft') | (istate == 'proforma'): state = 'waiting' elif istate == 'open': state = 'invoiced' elif istate == 'paid': state = 'paid' inv = self.pool.get('account.invoice').browse(cr, uid, fetched[1]) for payment in inv.payment_ids: if payment.invoice and payment.invoice.type == 'out_refund': state = 'canceled' elif istate == 'cancel': state = 'canceled' res[line.id] = state return res |
'state': fields.function(_state, method=True, string='Membership State', type='selection', selection=STATE, store=True), | 'state': fields.function( _state, method=True, string='Membership State', type='selection', selection=STATE, store = { 'account.invoice':(_get_membership_lines, ['state'], 10), }), | def _state(self, cr, uid, ids, name, args, context=None): """Compute the state lines @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 Membership Line IDs @param name: Field Name @param context: A standard dictionary for contextual values @param return: Dictionary of state Value """ res = {} for line in self.browse(cr, uid, ids): cr.execute(''' SELECT i.state, i.id FROM account_invoice i WHERE i.id = ( SELECT l.invoice_id FROM account_invoice_line l WHERE l.id = ( SELECT ml.account_invoice_line FROM membership_membership_line ml WHERE ml.id = %s ) ) ''', (line.id,)) fetched = cr.fetchone() if not fetched : res[line.id] = 'canceled' continue istate = fetched[0] state = 'none' if (istate == 'draft') | (istate == 'proforma'): state = 'waiting' elif istate == 'open': state = 'invoiced' elif istate == 'paid': state = 'paid' inv = self.pool.get('account.invoice').browse(cr, uid, fetched[1]) for payment in inv.payment_ids: if payment.invoice and payment.invoice.type == 'out_refund': state = 'canceled' elif istate == 'cancel': state = 'canceled' res[line.id] = state return res |
data_inv = member_line_obj.browse(cr, uid, ids, context) | data_inv = member_line_obj.browse(cr, uid, ids, context=context) | def _get_partner_id(self, cr, uid, ids, context=None): member_line_obj = self.pool.get('membership.membership_line') res_obj = self.pool.get('res.partner') data_inv = member_line_obj.browse(cr, uid, ids, context) list_partner = [] for data in data_inv: list_partner.append(data.partner.id) ids2 = list_partner while ids2: ids2 = res_obj.search(cr, uid, [('associate_member','in',ids2)], context=context) list_partner += ids2 return list_partner |
data_inv = inv_obj.browse(cr, uid, ids, context) | data_inv = inv_obj.browse(cr, uid, ids, context=context) | def _get_invoice_partner(self, cr, uid, ids, context=None): inv_obj = self.pool.get('account.invoice') res_obj = self.pool.get('res.partner') data_inv = inv_obj.browse(cr, uid, ids, context) list_partner = [] for data in data_inv: list_partner.append(data.partner_id.id) ids2 = list_partner while ids2: ids2 = res_obj.search(cr, uid, [('associate_member','in',ids2)], context=context) list_partner += ids2 return list_partner |
partner_data = self.browse(cr, uid, id) | partner_data = self.browse(cr, uid, id, context=context) | def _membership_state(self, cr, uid, ids, name, args, context=None): """This Function return Membership State For Given Partner. @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 Partner IDs @param name: Field Name @param context: A standard dictionary for contextual values @param return: Dictionary of Membership state Value """ res = {} for id in ids: res[id] = 'none' today = time.strftime('%Y-%m-%d') for id in ids: partner_data = self.browse(cr, uid, id) if partner_data.membership_cancel and today > partner_data.membership_cancel: res[id] = 'canceled' continue if partner_data.membership_stop and today > partner_data.membership_stop: res[id] = 'old' continue s = 4 if partner_data.member_lines: for mline in partner_data.member_lines: if mline.date_to >= today: if mline.account_invoice_line and mline.account_invoice_line.invoice_id: mstate = mline.account_invoice_line.invoice_id.state if mstate == 'paid': s = 0 inv = mline.account_invoice_line.invoice_id for payment in inv.payment_ids: if payment.invoice.type == 'out_refund': s = 2 break elif mstate == 'open' and s!=0: s = 1 elif mstate == 'cancel' and s!=0 and s!=1: s = 2 elif (mstate == 'draft' or mstate == 'proforma') and s!=0 and s!=1: s = 3 if s==4: for mline in partner_data.member_lines: if mline.date_from < today and mline.date_to < today and mline.date_from<=mline.date_to and (mline.account_invoice_line and mline.account_invoice_line.invoice_id.state) == 'paid': s = 5 else: s = 6 if s==0: res[id] = 'paid' elif s==1: res[id] = 'invoiced' elif s==2: res[id] = 'canceled' elif s==3: res[id] = 'waiting' elif s==5: res[id] = 'old' elif s==6: res[id] = 'none' if partner_data.free_member and s!=0: res[id] = 'free' if partner_data.associate_member: res_state = self._membership_state(cr, uid, [partner_data.associate_member.id], name, args, context) res[id] = res_state[partner_data.associate_member.id] return res |
res_state = self._membership_state(cr, uid, [partner_data.associate_member.id], name, args, context) | res_state = self._membership_state(cr, uid, [partner_data.associate_member.id], name, args, context=context) | def _membership_state(self, cr, uid, ids, name, args, context=None): """This Function return Membership State For Given Partner. @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 Partner IDs @param name: Field Name @param context: A standard dictionary for contextual values @param return: Dictionary of Membership state Value """ res = {} for id in ids: res[id] = 'none' today = time.strftime('%Y-%m-%d') for id in ids: partner_data = self.browse(cr, uid, id) if partner_data.membership_cancel and today > partner_data.membership_cancel: res[id] = 'canceled' continue if partner_data.membership_stop and today > partner_data.membership_stop: res[id] = 'old' continue s = 4 if partner_data.member_lines: for mline in partner_data.member_lines: if mline.date_to >= today: if mline.account_invoice_line and mline.account_invoice_line.invoice_id: mstate = mline.account_invoice_line.invoice_id.state if mstate == 'paid': s = 0 inv = mline.account_invoice_line.invoice_id for payment in inv.payment_ids: if payment.invoice.type == 'out_refund': s = 2 break elif mstate == 'open' and s!=0: s = 1 elif mstate == 'cancel' and s!=0 and s!=1: s = 2 elif (mstate == 'draft' or mstate == 'proforma') and s!=0 and s!=1: s = 3 if s==4: for mline in partner_data.member_lines: if mline.date_from < today and mline.date_to < today and mline.date_from<=mline.date_to and (mline.account_invoice_line and mline.account_invoice_line.invoice_id.state) == 'paid': s = 5 else: s = 6 if s==0: res[id] = 'paid' elif s==1: res[id] = 'invoiced' elif s==2: res[id] = 'canceled' elif s==3: res[id] = 'waiting' elif s==5: res[id] = 'old' elif s==6: res[id] = 'none' if partner_data.free_member and s!=0: res[id] = 'free' if partner_data.associate_member: res_state = self._membership_state(cr, uid, [partner_data.associate_member.id], name, args, context) res[id] = res_state[partner_data.associate_member.id] return res |
for partner in self.browse(cr, uid, ids): | for partner in self.browse(cr, uid, ids, context=context): | def _membership_date(self, cr, uid, ids, name, args, context=None): |
limit=1, order='date_from') | limit=1, order='date_from', context=context) | def _membership_date(self, cr, uid, ids, name, args, context=None): |
['date_from'])['date_from'] | ['date_from'], context=context)['date_from'] | def _membership_date(self, cr, uid, ids, name, args, context=None): |
limit=1, order='date_to desc') | limit=1, order='date_to desc', context=context) | def _membership_date(self, cr, uid, ids, name, args, context=None): |
['date_to'])['date_to'] | ['date_to'], context=context)['date_to'] | def _membership_date(self, cr, uid, ids, name, args, context=None): |
line_id2 = member_line_obj.search(cr, uid, [('partner', '=', partner.id)],limit=1, order='date_cancel') | line_id2 = member_line_obj.search(cr, uid, [('partner', '=', partner.id)], limit=1, order='date_cancel', context=context) | def _membership_date(self, cr, uid, ids, name, args, context=None): |
res[partner.id]['membership_cancel'] = member_line_obj.read(cr, uid, line_id2[0],['date_cancel'])['date_cancel'] | res[partner.id]['membership_cancel'] = member_line_obj.read(cr, uid, line_id2[0], ['date_cancel'], context=context)['date_cancel'] | def _membership_date(self, cr, uid, ids, name, args, context=None): |
return super(Partner, self).copy(cr, uid, id, default, context) | return super(Partner, self).copy(cr, uid, id, default, context=context) | def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} if context is None: context = {} default = default.copy() default['member_lines'] = [] return super(Partner, self).copy(cr, uid, id, default, context) |
} ) | }, context=context) | def create_membership_invoice(self, cr, uid, ids, product_id=None, datas=None, context=None): """ Create Customer Invoice of Membership for partners. @param datas: datas has dictionary value which consist Id of Membership product and Cost Amount of Membership. datas = {'membership_product_id': None, 'amount':None} """ invoice_obj = self.pool.get('account.invoice') product_obj = self.pool.get('product.product') invoice_line_obj = self.pool.get('account.invoice.line') invoice_tax_obj = self.pool.get('account.invoice.tax') product_id = product_id or datas.get('membership_product_id',False) amount = datas.get('amount', 0.0) if not context: context={} invoice_list = [] if type(ids) in (int,long,): ids = [ids] for partner in self.browse(cr, uid, ids, context=context): account_id = partner.property_account_receivable and partner.property_account_receivable.id or False fpos_id = partner.property_account_position and partner.property_account_position.id or False addr = self.address_get(cr, uid, [partner.id], ['invoice']) if partner.free_member: raise osv.except_osv(_('Error !'), _("Partner is a free Member.")) if not addr.get('invoice', False): raise osv.except_osv(_('Error !'), _("Partner doesn't have an address to make the invoice.")) quantity = 1 line_value = { 'product_id' : product_id, } |
model_data_ids_form = model_obj.search(cr,user,[('model','=','ir.ui.view'),('name','in',['membership_products_form','membership_products_tree'])]) resource_id_form = model_obj.read(cr, user, model_data_ids_form, fields=['res_id','name']) | model_data_ids_form = model_obj.search(cr,user,[('model','=','ir.ui.view'),('name','in',['membership_products_form','membership_products_tree'])], context=context) resource_id_form = model_obj.read(cr, user, model_data_ids_form, fields=['res_id','name'], context=context) | def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): model_obj = self.pool.get('ir.model.data') |
def action_cancel(self, cr, uid, ids, context=None): | def action_cancel(self, cr, uid, ids, *args): | def action_cancel(self, cr, uid, ids, context=None): '''Create a 'date_cancel' on the membership_line object''' if context is None: context = {} member_line_obj = self.pool.get('membership.membership_line') today = time.strftime('%Y-%m-%d') for invoice in self.browse(cr, uid, ids): mlines = member_line_obj.search(cr, uid, [('account_invoice_line','in', [ l.id for l in invoice.invoice_line])], context) member_line_obj.write(cr, uid, mlines, {'date_cancel':today}, context) return super(Invoice, self).action_cancel(cr, uid, ids, context) |
if context is None: context = {} | def action_cancel(self, cr, uid, ids, context=None): '''Create a 'date_cancel' on the membership_line object''' if context is None: context = {} member_line_obj = self.pool.get('membership.membership_line') today = time.strftime('%Y-%m-%d') for invoice in self.browse(cr, uid, ids): mlines = member_line_obj.search(cr, uid, [('account_invoice_line','in', [ l.id for l in invoice.invoice_line])], context) member_line_obj.write(cr, uid, mlines, {'date_cancel':today}, context) return super(Invoice, self).action_cancel(cr, uid, ids, context) |
|
[ l.id for l in invoice.invoice_line])], context) member_line_obj.write(cr, uid, mlines, {'date_cancel':today}, context) return super(Invoice, self).action_cancel(cr, uid, ids, context) | [ l.id for l in invoice.invoice_line])]) member_line_obj.write(cr, uid, mlines, {'date_cancel':today}) return super(Invoice, self).action_cancel(cr, uid, ids) | def action_cancel(self, cr, uid, ids, context=None): '''Create a 'date_cancel' on the membership_line object''' if context is None: context = {} member_line_obj = self.pool.get('membership.membership_line') today = time.strftime('%Y-%m-%d') for invoice in self.browse(cr, uid, ids): mlines = member_line_obj.search(cr, uid, [('account_invoice_line','in', [ l.id for l in invoice.invoice_line])], context) member_line_obj.write(cr, uid, mlines, {'date_cancel':today}, context) return super(Invoice, self).action_cancel(cr, uid, ids, context) |
for line in self.browse(cr, uid, ids): | for line in self.browse(cr, uid, ids, context=context): | def write(self, cr, uid, ids, vals, context=None): """Overrides orm write method """ if not context: context={} res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context) member_line_obj = self.pool.get('membership.membership_line') for line in self.browse(cr, uid, ids): if line.invoice_id.type == 'out_invoice': ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)]) if line.product_id and line.product_id.membership and not ml_ids: # Product line has changed to a membership product date_from = line.product_id.membership_date_from date_to = line.product_id.membership_date_to if line.invoice_id.date_invoice > date_from and line.invoice_id.date_invoice < date_to: date_from = line.invoice_id.date_invoice line_id = member_line_obj.create(cr, uid, { 'partner': line.invoice_id.partner_id.id, 'membership_id': line.product_id.id, 'member_price': line.price_unit, 'date': time.strftime('%Y-%m-%d'), 'date_from': date_from, 'date_to': date_to, 'account_invoice_line': line.id, }) if line.product_id and not line.product_id.membership and ml_ids: # Product line has changed to a non membership product member_line_obj.unlink(cr, uid, ml_ids, context=context) return res |
ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)]) | ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)], context=context) | def write(self, cr, uid, ids, vals, context=None): """Overrides orm write method """ if not context: context={} res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context) member_line_obj = self.pool.get('membership.membership_line') for line in self.browse(cr, uid, ids): if line.invoice_id.type == 'out_invoice': ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)]) if line.product_id and line.product_id.membership and not ml_ids: # Product line has changed to a membership product date_from = line.product_id.membership_date_from date_to = line.product_id.membership_date_to if line.invoice_id.date_invoice > date_from and line.invoice_id.date_invoice < date_to: date_from = line.invoice_id.date_invoice line_id = member_line_obj.create(cr, uid, { 'partner': line.invoice_id.partner_id.id, 'membership_id': line.product_id.id, 'member_price': line.price_unit, 'date': time.strftime('%Y-%m-%d'), 'date_from': date_from, 'date_to': date_to, 'account_invoice_line': line.id, }) if line.product_id and not line.product_id.membership and ml_ids: # Product line has changed to a non membership product member_line_obj.unlink(cr, uid, ml_ids, context=context) return res |
}) | }, context=context) | def write(self, cr, uid, ids, vals, context=None): """Overrides orm write method """ if not context: context={} res = super(account_invoice_line, self).write(cr, uid, ids, vals, context=context) member_line_obj = self.pool.get('membership.membership_line') for line in self.browse(cr, uid, ids): if line.invoice_id.type == 'out_invoice': ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)]) if line.product_id and line.product_id.membership and not ml_ids: # Product line has changed to a membership product date_from = line.product_id.membership_date_from date_to = line.product_id.membership_date_to if line.invoice_id.date_invoice > date_from and line.invoice_id.date_invoice < date_to: date_from = line.invoice_id.date_invoice line_id = member_line_obj.create(cr, uid, { 'partner': line.invoice_id.partner_id.id, 'membership_id': line.product_id.id, 'member_price': line.price_unit, 'date': time.strftime('%Y-%m-%d'), 'date_from': date_from, 'date_to': date_to, 'account_invoice_line': line.id, }) if line.product_id and not line.product_id.membership and ml_ids: # Product line has changed to a non membership product member_line_obj.unlink(cr, uid, ml_ids, context=context) return res |
ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',id)]) | ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',id)], context=context) | def unlink(self, cr, uid, ids, context=None): """Remove Membership Line Record for Account Invoice Line """ if not context: context={} member_line_obj = self.pool.get('membership.membership_line') for id in ids: ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',id)]) member_line_obj.unlink(cr, uid, ml_ids, context=context) return super(account_invoice_line, self).unlink(cr, uid, ids, context=context) |
def create(self, cr, uid, vals, context={}): | def create(self, cr, uid, vals, context=None): | def create(self, cr, uid, vals, context={}): """Overrides orm create method """ result = super(account_invoice_line, self).create(cr, uid, vals, context) line = self.browse(cr, uid, result) member_line_obj = self.pool.get('membership.membership_line') if line.invoice_id.type == 'out_invoice': |
result = super(account_invoice_line, self).create(cr, uid, vals, context) line = self.browse(cr, uid, result) | result = super(account_invoice_line, self).create(cr, uid, vals, context=context) line = self.browse(cr, uid, result, context=context) | def create(self, cr, uid, vals, context={}): """Overrides orm create method """ result = super(account_invoice_line, self).create(cr, uid, vals, context) line = self.browse(cr, uid, result) member_line_obj = self.pool.get('membership.membership_line') if line.invoice_id.type == 'out_invoice': |
ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)]) | ml_ids = member_line_obj.search(cr, uid, [('account_invoice_line','=',line.id)], context=context) | def create(self, cr, uid, vals, context={}): """Overrides orm create method """ result = super(account_invoice_line, self).create(cr, uid, vals, context) line = self.browse(cr, uid, result) member_line_obj = self.pool.get('membership.membership_line') if line.invoice_id.type == 'out_invoice': |
}) | }, context=context) | def create(self, cr, uid, vals, context={}): """Overrides orm create method """ result = super(account_invoice_line, self).create(cr, uid, vals, context) line = self.browse(cr, uid, result) member_line_obj = self.pool.get('membership.membership_line') if line.invoice_id.type == 'out_invoice': |
run = False if transition.trigger != 'signal' and campaign_mode != 'manual': if transition.trigger == 'auto' or campaign_mode == 'test': run = True | run = transition.trigger == 'auto' \ or (transition.trigger == 'time' \ and campaign_mode == 'test') | def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return |
'get_contract':self.get_contract, | def __init__(self, cr, uid, name, context): super(salary_structure_report, self).__init__(cr, uid, name, context) self.localcontext.update({ 'time': time, 'get_type':self.get_type, 'get_contract':self.get_contract, 'get_line_amount_type':self.get_line_amount_type, 'get_line_type':self.get_line_type, 'get_line_amount_symbol':self.get_line_amount_symbol }) |
|
def get_contract(self,emp): curr_date = "'"+time.strftime("%Y-%m-%d")+"'" sql_req= ''' SELECT c.id as id, c.wage as wage, struct_id as struct FROM hr_contract c LEFT JOIN hr_employee emp on (c.employee_id=emp.id) LEFT JOIN hr_contract_wage_type cwt on (cwt.id = c.wage_type_id) LEFT JOIN hr_contract_wage_type_period p on (cwt.period_id = p.id) WHERE (emp.id=%s) AND (date_start <= %s) AND (date_end IS NULL OR date_end >= %s) LIMIT 1 '''%(emp.id, curr_date, curr_date) self.cr.execute(sql_req) contract_id = self.cr.dictfetchone() if not contract_id: return [] contract = self.pool.get('hr.contract').browse(self.cr, self.uid, [contract_id['id']]) return contract | def get_contract(self,emp): curr_date = "'"+time.strftime("%Y-%m-%d")+"'" sql_req= ''' SELECT c.id as id, c.wage as wage, struct_id as struct FROM hr_contract c LEFT JOIN hr_employee emp on (c.employee_id=emp.id) LEFT JOIN hr_contract_wage_type cwt on (cwt.id = c.wage_type_id) LEFT JOIN hr_contract_wage_type_period p on (cwt.period_id = p.id) WHERE (emp.id=%s) AND (date_start <= %s) AND (date_end IS NULL OR date_end >= %s) LIMIT 1 '''%(emp.id, curr_date, curr_date) self.cr.execute(sql_req) contract_id = self.cr.dictfetchone() if not contract_id: return [] contract = self.pool.get('hr.contract').browse(self.cr, self.uid, [contract_id['id']]) return contract |
|
tools.drop_view_if_exists(cr, 'stock_report_prodlots') | drop_view_if_exists(cr, 'stock_report_prodlots') | def init(self, cr): tools.drop_view_if_exists(cr, 'stock_report_prodlots') cr.execute(""" create or replace view stock_report_prodlots as ( select max(id) as id, location_id, product_id, prodlot_id, sum(qty) as name from ( select -max(sm.id) as id, sm.location_id, sm.product_id, sm.prodlot_id, -sum(sm.product_qty /uo.factor) as qty from stock_move as sm left join stock_location sl on (sl.id = sm.location_id) left join product_uom uo on (uo.id=sm.product_uom) where state = 'done' group by sm.location_id, sm.product_id, sm.product_uom, sm.prodlot_id union all select max(sm.id) as id, sm.location_dest_id as location_id, sm.product_id, sm.prodlot_id, sum(sm.product_qty /uo.factor) as qty from stock_move as sm left join stock_location sl on (sl.id = sm.location_dest_id) left join product_uom uo on (uo.id=sm.product_uom) where sm.state = 'done' group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.prodlot_id ) as report group by location_id, product_id, prodlot_id )""") |
tools.drop_view_if_exists(cr, 'stock_report_tracklots') | drop_view_if_exists(cr, 'stock_report_prodlots') | def init(self, cr): tools.drop_view_if_exists(cr, 'stock_report_tracklots') cr.execute(""" create or replace view stock_report_tracklots as ( select max(id) as id, location_id, product_id, tracking_id, sum(qty) as name from ( select -max(sm.id) as id, sm.location_id, sm.product_id, sm.tracking_id, -sum(sm.product_qty /uo.factor) as qty from stock_move as sm left join stock_location sl on (sl.id = sm.location_id) left join product_uom uo on (uo.id=sm.product_uom) where state = 'done' group by sm.location_id, sm.product_id, sm.product_uom, sm.tracking_id union all select max(sm.id) as id, sm.location_dest_id as location_id, sm.product_id, sm.tracking_id, sum(sm.product_qty /uo.factor) as qty from stock_move as sm left join stock_location sl on (sl.id = sm.location_dest_id) left join product_uom uo on (uo.id=sm.product_uom) where sm.state = 'done' group by sm.location_dest_id, sm.product_id, sm.product_uom, sm.tracking_id ) as report group by location_id, product_id, tracking_id )""") |
tools.drop_view_if_exists(cr, 'report_stock_lines_date') | drop_view_if_exists(cr, 'stock_report_prodlots') | def init(self, cr): tools.drop_view_if_exists(cr, 'report_stock_lines_date') cr.execute(""" create or replace view report_stock_lines_date as ( select p.id as id, p.id as product_id, max(s.date) as date from product_product p left outer join stock_inventory_line l on (p.id=l.product_id) left join stock_inventory s on (l.inventory_id=s.id) and s.state = 'done' group by p.id )""") |
date_close = tasks[task.id][-1][1] | date_close = tasks[task.id] and tasks[task.id][-1][1] or False | def _compute_tasks(cr, uid, task_list, date_begin): sequences = [] users = {} tasks = {} last_date = date_begin for task in task_list: # TODO: reorder ! with dependencies if not task.planned_hours: continue if task.state in ('draft','open','progress') and task.user_id: # Find the starting date of the task if task.user_id.id in users: date_start = users[task.user_id.id] else: date_start = date_begin sequences.sort() for (seq,dt) in sequences: if seq<task.sequence: date_start = max(dt,date_start) else: break if task.date_start: task_date_start = DateTime.strptime(task.date_start, '%Y-%m-%d %H:%M:%S') if DateTime.cmp(date_start, task_date_start) < 0: date_start = task_date_start # Compute the closing date of the task tasks[task.id] = [] res = pooler.get_pool(cr.dbname).get('hr.timesheet.group').interval_get(cr, uid, task.project_id.timesheet_id.id, date_start, task.remaining_hours) for (d1,d2) in res: tasks[task.id].append((d1, d2, task.name, task.user_id.login)) date_close = tasks[task.id][-1][1] # Store result users[task.user_id.id] = date_close sequences.append((task.sequence, date_close)) if date_close>last_date: last_date=date_close return tasks, last_date |
users[task.user_id.id] = date_close sequences.append((task.sequence, date_close)) if date_close>last_date: last_date=date_close | if date_close: users[task.user_id.id] = date_close sequences.append((task.sequence, date_close)) if date_close>last_date: last_date=date_close | def _compute_tasks(cr, uid, task_list, date_begin): sequences = [] users = {} tasks = {} last_date = date_begin for task in task_list: # TODO: reorder ! with dependencies if not task.planned_hours: continue if task.state in ('draft','open','progress') and task.user_id: # Find the starting date of the task if task.user_id.id in users: date_start = users[task.user_id.id] else: date_start = date_begin sequences.sort() for (seq,dt) in sequences: if seq<task.sequence: date_start = max(dt,date_start) else: break if task.date_start: task_date_start = DateTime.strptime(task.date_start, '%Y-%m-%d %H:%M:%S') if DateTime.cmp(date_start, task_date_start) < 0: date_start = task_date_start # Compute the closing date of the task tasks[task.id] = [] res = pooler.get_pool(cr.dbname).get('hr.timesheet.group').interval_get(cr, uid, task.project_id.timesheet_id.id, date_start, task.remaining_hours) for (d1,d2) in res: tasks[task.id].append((d1, d2, task.name, task.user_id.login)) date_close = tasks[task.id][-1][1] # Store result users[task.user_id.id] = date_close sequences.append((task.sequence, date_close)) if date_close>last_date: last_date=date_close return tasks, last_date |
return user.context_section_id | print "section id",type(user.context_section_id) return int(user.context_section_id) | def _get_section(self, cr, uid, context): user = self.pool.get('res.users').browse(cr,uid,uid,context=context) return user.context_section_id |
GROUP BY partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from)) | GROUP BY l.partner_id ', (tuple(move_state), tuple(self.ACCOUNT_TYPE), tuple(partner_ids), self.date_from)) | def _get_lines(self, form): res = [] self.cr.execute('SELECT DISTINCT res_partner.id AS id,\ res_partner.name AS name \ FROM res_partner,account_move_line AS l, account_account\ WHERE (l.account_id=account_account.id) \ AND ((reconcile_id IS NULL)\ OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\ AND (l.partner_id=res_partner.id)\ AND ' + self.query + ' \ ORDER BY res_partner.name', (self.date_from,)) partners = self.cr.dictfetchall() ## mise a 0 du total for i in range(7): self.total_account.append(0) # # Build a string like (1,2,3) for easy use in SQL query partner_ids = [x['id'] for x in partners] if not partner_ids: return [] # This dictionary will store the debit-credit for all partners, using partner_id as key. move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted'] |
if not password: return False | try: return self._login(db, login, password) except Exception, e: import logging logging.getLogger('netsvc').exception('Could not authenticate') return Exception('Access Denied') def _login(self, db, login, password): if not password: return False if db is False: raise RuntimeError("Cannot authenticate to False db!") | def login(self, db, login, password): |
action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) | action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) | def fetch_mail(self, cr, uid, ids, context={}): email_tool = self.pool.get('email.server.tools') action_pool = self.pool.get('ir.actions.server') context.update({'get_server': True}) for server in self.browse(cr, uid, ids, context): count = 0 user = server.user_id.id or uid try: if server.type == 'imap': imap_server = self.button_confirm_login(cr, uid, [server.id], context=context) imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') for num in data[0].split(): result, data = imap_server.fetch(num, '(RFC822)') res_id = email_tool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context) if res_id and server.action_id: action_pool.run(cr, uid, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) |
res = node.open_data(cr, mode) | try: res = node.open_data(cr, mode) except TypeError, e: raise IOError(errno.EINVAL, "No data") | def open(self, datacr, mode): if not (datacr and datacr[1]): raise OSError(1, 'Operation not permited.') # Reading operation cr, node, rem = datacr res = node.open_data(cr, mode) return res |
def _get_fiscalyear(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).fiscalyear_id.name return super(journal_print ,self)._get_fiscalyear(data) | def _sum_currency_amount_account(self, account, form): self._set_get_account_currency_code(account.id) self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) total = self.cr.fetchone() |
|
cr.execute(sql,(data['form']['date1'])) | cr.execute(sql,(data['form']['date1'],)) | def _check_date(self, cr, uid, data, context): |
def _get_chart_account(cursor, user, account): if account.parent_id: chart_account = _get_chart_account(cursor, user, account.parent_id) else: chart_account = account return chart_account | def _get_chart_account(cursor, user, account): if account.parent_id: chart_account = _get_chart_account(cursor, user, account.parent_id) else: chart_account = account return chart_account |
|
s = decode_header(s) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s)) | s = decode_header(s) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s or [])) | def _decode_header(self, s): from email.Header import decode_header s = decode_header(s) return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s)) |
'title': lead.title, | 'title': lead.title and lead.title.id or False, | def _create_partner(self, cr, uid, ids, context=None): """ This function Creates partner based on action. @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Lead to Partner's IDs @param context: A standard dictionary for contextual values |
computed_taxes = account_tax_obj.compute( | computed_taxes = account_tax_objcompute_all( | order_account = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def or curr_c.account_receivable.id |
computed_taxes = account_tax_obj.compute(cr, uid, taxes, line.price_unit, line.qty) | computed_taxes = account_tax_objcompute_all(cr, uid, taxes, line.price_unit, line.qty) | def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context): res = {} account_tax_obj = self.pool.get('account.tax') for line in self.browse(cr, uid, ids): tax_amount = 0.0 taxes = [t for t in line.product_id.taxes_id] computed_taxes = account_tax_obj.compute(cr, uid, taxes, line.price_unit, line.qty) for tax in computed_taxes: tax_amount += tax['amount'] price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) if line.discount!=0.0: res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0) else: res[line.id]=line.price_unit*line.qty res[line.id] = res[line.id] + tax_amount return res |
search_arg = ['|', ('first_name', 'ilike', arg[2]), ('name', 'ilike', arg[2])] contact_ids = contact_obj.search(cr, user, search_arg, offset=offset, \ limit=limit, order=order, context=context, count=count) contacts = contact_obj.browse(cr, user, contact_ids, context=context) for contact in contacts: job_ids.extend([item.id for item in contact.job_ids]) | if arg[2] and not count: search_arg = ['|', ('first_name', 'ilike', arg[2]), ('name', 'ilike', arg[2])] contact_ids = contact_obj.search(cr, user, search_arg, offset=offset, limit=limit, order=order, context=context, count=count) contacts = contact_obj.browse(cr, user, contact_ids, context=context) for contact in contacts: job_ids.extend([item.id for item in contact.job_ids]) | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): """ search parnter job @param self: The object pointer @param cr: the current row, from the database cursor, @param user: the current user @param args: list of tuples of form [(‘name_of_the_field’, ‘operator’, value), ...]. @param offset: The Number of Results to Pass @param limit: The Number of Results to Return @param context: A standard dictionary for contextual values """ |
import pdb pdb.set_trace() | def set_context(self, objects, data, ids, report_type = None): new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = 'active_ids' in data['form'] and data['form']['active_ids'] or [] objects = self.pool.get('account.journal.period').browse(self.cr, self.uid, new_ids) import pdb pdb.set_trace() super(journal_print, self).set_context(objects, data, new_ids, report_type) |
|
m2o_order = m2o_order.split(",",1)[0].strip().split(" ",1)[0] | m2o_order_list = [] for order_part in m2o_order.split(",",1): m2o_order_list.append(order_part.strip().split(" ",1)[0].strip()) m2o_order = m2o_order_list | def _generate_m2o_order_by(self, order_field, query): """ Add possibly missing JOIN to ``query`` and generate the ORDER BY clause for m2o fields, either native m2o fields or function/related fields that are stored, including intermediate JOINs for inheritance if required. |
return '"%s"."%s"' % (dest_model._table, m2o_order) | qualify = lambda field: '"%s"."%s"' % (dest_model._table, field) return map(qualify, m2o_order) if isinstance(m2o_order, list) else qualify(m2o_order) | def _generate_m2o_order_by(self, order_field, query): """ Add possibly missing JOIN to ``query`` and generate the ORDER BY clause for m2o fields, either native m2o fields or function/related fields that are stored, including intermediate JOINs for inheritance if required. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.