rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
location = baseuri + self.redirect_paths[self.path]
location = baseuri + redir_path
def send_head(self): """Common code for GET and HEAD commands.
self._logger.debug("redirecting %s to %s", self.path, self.redirect_paths[self.path])
self._logger.debug("redirecting %s to %s", self.path, redir_path)
def send_head(self): """Common code for GET and HEAD commands.
currency = self.pool.get('res.currency').browse(cr, uid, currency_id) currency_obj.round(cr, uid, currency, 300)
currency = currency_obj.browse(cr, uid, currency_id)
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 """ prod_id = context and context.get('product_id', False)
def get_currency_id(self, cursor, user, picking):
def get_currency_id(self, cr, uid, picking):
def get_currency_id(self, cursor, user, picking): return False
def _get_payment_term(self, cursor, user, picking):
def _get_payment_term(self, cr, uid, picking):
def _get_payment_term(self, cursor, user, picking): '''Return {'contact': address, 'invoice': address} for invoice''' partner_obj = self.pool.get('res.partner') partner = picking.address_id.partner_id return partner.property_payment_term and partner.property_payment_term.id or False
def _get_address_invoice(self, cursor, user, picking):
def _get_address_invoice(self, cr, uid, picking):
def _get_address_invoice(self, cursor, user, picking): '''Return {'contact': address, 'invoice': address} for invoice''' partner_obj = self.pool.get('res.partner') partner = picking.address_id.partner_id
return partner_obj.address_get(cursor, user, [partner.id],
return partner_obj.address_get(cr, uid, [partner.id],
def _get_address_invoice(self, cursor, user, picking): '''Return {'contact': address, 'invoice': address} for invoice''' partner_obj = self.pool.get('res.partner') partner = picking.address_id.partner_id
def _get_comment_invoice(self, cursor, user, picking):
def _get_comment_invoice(self, cr, uid, picking):
def _get_comment_invoice(self, cursor, user, picking): '''Return comment string for invoice''' return picking.note or ''
def _get_price_unit_invoice(self, cursor, user, move_line, type):
def _get_price_unit_invoice(self, cr, uid, move_line, type, context=None):
def _get_price_unit_invoice(self, cursor, user, move_line, type): '''Return the price unit for the move line''' if type in ('in_invoice', 'in_refund'): # Take the user company and pricetype price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) context['currency_id']=move_line.company_id.currency_id.id amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id] return amount_unit else: return move_line.product_id.list_price
price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) context['currency_id']=move_line.company_id.currency_id.id amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
price_type_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.property_valuation_price_type.id pricetype = self.pool.get('product.price.type').browse(cr, uid, price_type_id) context['currency_id'] = move_line.company_id.currency_id.id amount_unit = move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
def _get_price_unit_invoice(self, cursor, user, move_line, type): '''Return the price unit for the move line''' if type in ('in_invoice', 'in_refund'): # Take the user company and pricetype price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id) context['currency_id']=move_line.company_id.currency_id.id amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id] return amount_unit else: return move_line.product_id.list_price
def _get_discount_invoice(self, cursor, user, move_line):
def _get_discount_invoice(self, cr, uid, move_line):
def _get_discount_invoice(self, cursor, user, move_line): '''Return the discount for the move line''' return 0.0
def _get_taxes_invoice(self, cursor, user, move_line, type):
def _get_taxes_invoice(self, cr, uid, move_line, type):
def _get_taxes_invoice(self, cursor, user, move_line, type): '''Return taxes ids for the move line''' if type in ('in_invoice', 'in_refund'): taxes = move_line.product_id.supplier_taxes_id else: taxes = move_line.product_id.taxes_id
cursor, user,
cr, uid,
def _get_taxes_invoice(self, cursor, user, move_line, type): '''Return taxes ids for the move line''' if type in ('in_invoice', 'in_refund'): taxes = move_line.product_id.supplier_taxes_id else: taxes = move_line.product_id.taxes_id
def _get_account_analytic_invoice(self, cursor, user, picking, move_line):
def _get_account_analytic_invoice(self, cr, uid, picking, move_line):
def _get_account_analytic_invoice(self, cursor, user, picking, move_line): return False
def _invoice_line_hook(self, cursor, user, move_line, invoice_line_id):
def _invoice_line_hook(self, cr, uid, move_line, invoice_line_id):
def _invoice_line_hook(self, cursor, user, move_line, invoice_line_id): '''Call after the creation of the invoice line''' return
def _invoice_hook(self, cursor, user, picking, invoice_id):
def _invoice_hook(self, cr, uid, picking, invoice_id):
def _invoice_hook(self, cursor, user, picking, invoice_id): '''Call after the creation of the invoice''' return
def action_invoice_create(self, cursor, user, ids, journal_id=False,
def action_invoice_create(self, cr, uid, ids, journal_id=False,
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
for picking in self.browse(cursor, user, ids, context=context):
for picking in self.browse(cr, uid, ids, context=context):
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
payment_term_id = self._get_payment_term(cursor, user, picking)
payment_term_id = self._get_payment_term(cr, uid, picking)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
self._get_address_invoice(cursor, user, picking).values() comment = self._get_comment_invoice(cursor, user, picking)
self._get_address_invoice(cr, uid, picking).values() comment = self._get_comment_invoice(cr, uid, picking)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
invoice = invoice_obj.browse(cursor, user, invoice_id)
invoice = invoice_obj.browse(cr, uid, invoice_id)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
invoice_obj.write(cursor, user, [invoice_id], invoice_vals, context=context)
invoice_obj.write(cr, uid, [invoice_id], invoice_vals, context=context)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
cur_id = self.get_currency_id(cursor, user, picking)
cur_id = self.get_currency_id(cr, uid, picking)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
invoice_id = invoice_obj.create(cursor, user, invoice_vals,
invoice_id = invoice_obj.create(cr, uid, invoice_vals,
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
price_unit = self._get_price_unit_invoice(cursor, user,
price_unit = self._get_price_unit_invoice(cr, uid,
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
discount = self._get_discount_invoice(cursor, user, move_line) tax_ids = self._get_taxes_invoice(cursor, user, move_line, type) account_analytic_id = self._get_account_analytic_invoice(cursor, user, picking, move_line)
discount = self._get_discount_invoice(cr, uid, move_line) tax_ids = self._get_taxes_invoice(cr, uid, move_line, type) account_analytic_id = self._get_account_analytic_invoice(cr, uid, picking, move_line)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
account_id = self.pool.get('account.fiscal.position').map_account(cursor, user, partner.property_account_position, account_id)
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, partner.property_account_position, account_id)
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
invoice_line_id = invoice_line_obj.create(cursor, user, {
invoice_line_id = invoice_line_obj.create(cr, uid, {
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
self._invoice_line_hook(cursor, user, move_line, invoice_line_id) invoice_obj.button_compute(cursor, user, [invoice_id], context=context,
self._invoice_line_hook(cr, uid, move_line, invoice_line_id) invoice_obj.button_compute(cr, uid, [invoice_id], context=context,
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
self.write(cursor, user, [picking.id], {
self.write(cr, uid, [picking.id], {
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
self._invoice_hook(cursor, user, picking, invoice_id) self.write(cursor, user, res.keys(), {
self._invoice_hook(cr, uid, picking, invoice_id) self.write(cr, uid, res.keys(), {
def action_invoice_create(self, cursor, user, ids, journal_id=False, group=False, type='out_invoice', context=None): '''Return ids of created invoices for the pickings''' invoice_obj = self.pool.get('account.invoice') invoice_line_obj = self.pool.get('account.invoice.line') invoices_group = {} res = {}
ids = self.search(cr, user, args, limit=limit, context=context)
if name: ids = self.search(cr, user, [('description', '=', name)] + args, limit=limit, context=context) if not ids: ids = self.search(cr, user, [('name', operator, name)] + args, limit=limit, context=context) else: ids = self.search(cr, user, args, limit=limit, context=context or {})
Returns a list of tupples containing id, name, as internally it is called {def name_get}
self.ical_set(cal_data.name.lower(), {'name':cal_data.params['CN']}, 'value')
self.ical_set(cal_data.name.lower(), {'name': cal_data.params['CN'][0]}, 'value') continue
def parse_ics(self, cr, uid, child, cal_children=None, context=None): """ parse 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 """
'sum_currency_amount_account': self._sum_currency_amount_account,
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, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_account': self._get_account, 'get_filter': self._get_filter, 'get_start_date': self._get_start_date, 'get_end_date': self._get_end_date, 'sum_currency_amount_account': self._sum_currency_amount_account, 'get_fiscalyear': self._get_fiscalyear, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'print_data':self._print_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() if self.account_currency: return_field = str(total[0]) + self.account_currency return return_field else: currency_total = self.tot_currency = 0.0 return currency_total
def _set_get_account_currency_code(self, account_id): self.cr.execute("SELECT c.code as code "\ "FROM res_currency c,account_account as ac "\ "WHERE ac.id = %s AND ac.currency_id = c.id"%(account_id)) result = self.cr.fetchone() if result: self.account_currency = result[0] else: self.account_currency = False
res=self.cr.fetchone()[0]
res=self.cr.fetchone()[0] or 0.0
def __pos_payment_date__total__(self,form): dt1 = form['date_start'] + ' 00:00:00' dt2 = form['date_end'] + ' 23:59:59' res=[] self.cr.execute ("select sum(pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0)) " \ "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 " \ "and po.state IN ('paid','invoiced') and po.date_order >= %s and po.date_order <= %s and po.user_id IN %s " \ ,(dt1,dt2,tuple(form['user_id']))) res=self.cr.fetchone()[0] return res
partner_data = res_obj.browse(cr, uid, part)
def onchange_partner_id(self, cr, uid, ids, part, event_id, email=False): """This function returns value of Patner Invoice id, Unit Price, badget title based on partner and 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 ids: List of Registration IDs @param event_id: Event ID @param partner_invoice_id: Partner Invoice ID """ job_obj = self.pool.get('res.partner.job') res_obj = self.pool.get('res.partner')
return obj_payment_order.set_done(cr, uid, context['active_id'], context)
obj_payment_order.set_done(cr, uid, context['active_id'], context) return {}
def launch_wizard(self, cr, uid, ids, context=None): """ Search for a wizard to launch according to the type. If type is manual. just confirm the order. """ obj_payment_order = self.pool.get('payment.order')
res = self.write(cr, uid, event_id, {'exdate': date_new})
exdate = (record['exdate'] and (record['exdate'] + ',') or '') + date_new res = self.write(cr, uid, event_id, {'exdate': exdate})
def unlink(self, cr, uid, ids, context=None): """ Deletes records specified in ids. @param self: the object pointer. @param cr: the current row, from the database cursor, @param id: List of calendar event's id. @param context: A standard dictionary for contextual values @return: True """ res = False for event_id in ids: if isinstance(event_id, (int, long)): res = super(calendar_event, self).unlink(cr, uid, event_id) self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name) continue event_id, date_new = event_id.split('-') event_id = [int(event_id)] for record in self.read(cr, uid, event_id, ['date', 'rrule', 'exdate'], context=context): if record['rrule']: # Remove one of the recurrent event date_new = time.strftime("%Y%m%dT%H%M%S", \ time.strptime(date_new, "%Y%m%d%H%M%S")) res = self.write(cr, uid, event_id, {'exdate': date_new}) else: res = super(calendar_event, self).unlink(cr, uid, event_id) self.pool.get('res.alarm').do_alarm_unlink(cr, uid, event_id, self._name) return res
default['backorder_id'] = False return super(stock_picking, self).copy(cr, uid, id, default, context)
default['backorder_id'] = False res=super(stock_picking, self).copy(cr, uid, id, default, context) if res: picking_obj = self.browse(cr, uid, [res], context)[0] for move in picking_obj.move_lines: move_obj.write(cr, uid, [move.id], {'tracking_id': False,'prodlot_id':False}) return res
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() picking_obj = self.browse(cr, uid, [id], context)[0] if ('name' not in default) or (picking_obj.name=='/'): seq_obj_name = 'stock.picking.' + picking_obj.type default['name'] = self.pool.get('ir.sequence').get(cr, uid, seq_obj_name) default['origin'] = '' default['backorder_id'] = False return super(stock_picking, self).copy(cr, uid, id, default, context)
def button_confirm(self, cr, uid, ids, *args): for id in ids: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', id, 'button_confirm', cr) self.force_assign(cr, uid, ids, *args) return True
def button_confirm(self, cr, uid, ids, *args): for id in ids: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', id, 'button_confirm', cr) self.force_assign(cr, uid, ids, *args) return True
class account_bank_statement_line(osv.osv): def _default_company(self, cr, uid, context={}): """ To get default company for the object" @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 bank statement ids @param context: A standard dictionary for contextual values @return: company """ user = self.pool.get('res.users').browse(cr, uid, uid, context=context) if user.company_id: return user.company_id.id return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _inherit = 'account.bank.statement.line' _columns = { 'company_id':fields.many2one('res.company', 'Company', required=True), } _defaults = { 'company_id': _default_company, } account_bank_statement_line()
def _user_allow(self, cr, uid, ids, statement, context={}): res = False uids = [] for user in statement.journal_id.journal_users: uids.append(user.id) if uid in uids: res = True return res
(check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password'])
(check_duplicate, 'Warning! Can\'t have duplicate server configuration!', ['user', 'password']), (check_model, 'Warning! Record for slected Model can not be created\nPlease choose valid Model', ['object_id'])
def check_duplicate(self, cr, uid, ids):
self.ical_set(cal_data.name.lower(), {'name': cal_data.params['CN'][0]}, 'value')
self.ical_set(cal_data.name.lower(), {'name': cal_data.params.get('CN') and cal_data.params.get('CN')[0]}, 'value')
def parse_ics(self, cr, uid, child, cal_children=None, context=None): """ parse 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 """
'product_qty': product_qty, 'product_uos_qty': product_qty
'product_qty': move.product_qty, 'product_uos_qty': move.product_qty
def do_partial(self, cr, uid, ids, partial_datas, context={}): """ @ partial_datas : dict. contain details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom """ res = {} picking_obj = self.pool.get('stock.picking') delivery_obj = self.pool.get('stock.delivery') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False)
sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id IN %s and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit""",(tuple(a_l),)
sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id = %d and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit"""%(o.id)
def _get_data(self,o): data={} sql1=""" SELECT distinct(o.id) from account_bank_statement s, account_bank_statement_line l,pos_order o,pos_order_line i where i.order_id=o.id and o.state='paid' and l.statement_id=s.id and l.pos_statement_id=o.id and s.id=%d"""%(o.id) self.cr.execute(sql1) data = self.cr.dictfetchall() a_l=[] for r in data: a_l.append(r['id']) if len(a_l): sql2="""SELECT sum(qty) as qty,l.price_unit*sum(l.qty) as amt,t.name as name from product_product p, product_template t, pos_order_line l where order_id IN %s and p.product_tmpl_id=t.id and l.product_id=p.id group by t.name, l.price_unit""",(tuple(a_l),) self.cr.execute(sql2) data = self.cr.dictfetchall() for d in data: self.total += d['amt'] return data
name = allocation.resource_id.name if allocation.user_id: name = '%s' %(allocation.user_id.name)
name = allocation.phase_id.name
def get_name(self, cr, uid, ids, field_name, arg, context=None): res = {} for allocation in self.browse(cr, uid, ids, context=context): name = allocation.resource_id.name if allocation.user_id: name = '%s' %(allocation.user_id.name) name += ' (%s%%)' %(allocation.useability) res[allocation.id] = name return res
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): todel=[] fiscalyear_obj = self.pool.get('account.fiscalyear') period_obj = self.pool.get('account.period') for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = period_obj.find(cr, uid)[0] domain.append(['period_id','in',[current_period]]) todel.append(arg) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) todel.append(arg) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby)
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None): todel=[] fiscalyear_obj = self.pool.get('account.fiscalyear') period_obj = self.pool.get('account.period') for arg in domain: if arg[0] == 'period_id' and arg[2] == 'current_period': current_period = period_obj.find(cr, uid)[0] domain.append(['period_id','in',[current_period]]) todel.append(arg) break elif arg[0] == 'period_id' and arg[2] == 'current_year': current_year = fiscalyear_obj.find(cr, uid) ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids'] domain.append(['period_id','in',ids]) todel.append(arg) for a in [['period_id','in','current_year'], ['period_id','in','current_period']]: if a in domain: domain.remove(a) return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
r = {}
def _debit_calc(self, cr, uid, ids, name, arg, context={}):
move_ids = []
def action_production_end(self, cr, uid, ids): move_ids = [] for production in self.browse(cr, uid, ids): for res in production.move_lines: for move in production.move_created_ids: #XXX must use the orm cr.execute('INSERT INTO stock_move_history_ids \ (parent_id, child_id) VALUES (%s,%s)', (res.id, move.id)) move_ids.append(res.id) vals= {'state':'confirmed'} new_moves = [x.id for x in production.move_created_ids] self.pool.get('stock.move').write(cr, uid, new_moves, vals) if not production.date_finnished: self.write(cr, uid, [production.id], {'date_finnished': time.strftime('%Y-%m-%d %H:%M:%S')}) self.pool.get('stock.move').check_assign(cr, uid, new_moves) self.pool.get('stock.move').action_done(cr, uid, new_moves) self._costs_generate(cr, uid, production) self.pool.get('stock.move').action_done(cr, uid, move_ids) self.write(cr, uid, ids, {'state': 'done'}) return True
move_ids.append(res.id)
def action_production_end(self, cr, uid, ids): move_ids = [] for production in self.browse(cr, uid, ids): for res in production.move_lines: for move in production.move_created_ids: #XXX must use the orm cr.execute('INSERT INTO stock_move_history_ids \ (parent_id, child_id) VALUES (%s,%s)', (res.id, move.id)) move_ids.append(res.id) vals= {'state':'confirmed'} new_moves = [x.id for x in production.move_created_ids] self.pool.get('stock.move').write(cr, uid, new_moves, vals) if not production.date_finnished: self.write(cr, uid, [production.id], {'date_finnished': time.strftime('%Y-%m-%d %H:%M:%S')}) self.pool.get('stock.move').check_assign(cr, uid, new_moves) self.pool.get('stock.move').action_done(cr, uid, new_moves) self._costs_generate(cr, uid, production) self.pool.get('stock.move').action_done(cr, uid, move_ids) self.write(cr, uid, ids, {'state': 'done'}) return True
self.pool.get('stock.move').action_done(cr, uid, new_moves)
def action_production_end(self, cr, uid, ids): move_ids = [] for production in self.browse(cr, uid, ids): for res in production.move_lines: for move in production.move_created_ids: #XXX must use the orm cr.execute('INSERT INTO stock_move_history_ids \ (parent_id, child_id) VALUES (%s,%s)', (res.id, move.id)) move_ids.append(res.id) vals= {'state':'confirmed'} new_moves = [x.id for x in production.move_created_ids] self.pool.get('stock.move').write(cr, uid, new_moves, vals) if not production.date_finnished: self.write(cr, uid, [production.id], {'date_finnished': time.strftime('%Y-%m-%d %H:%M:%S')}) self.pool.get('stock.move').check_assign(cr, uid, new_moves) self.pool.get('stock.move').action_done(cr, uid, new_moves) self._costs_generate(cr, uid, production) self.pool.get('stock.move').action_done(cr, uid, move_ids) self.write(cr, uid, ids, {'state': 'done'}) return True
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), context=context)
result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), date=time.strftime('%Y-%m-%d'), context=context)
def populate_statement(self, cr, uid, ids, context=None): if context is None: context = {} 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 {}
x_headers = { 'Reply-To':"%s" % case.section_id.reply_to, }
x_headers = dict()
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
params.append(max_amount)
params += max_amount
def reconcile(self, cr, uid, ids, context=None): move_line_obj = self.pool.get('account.move.line') obj_model = self.pool.get('ir.model.data') if context is None: context = {} form = self.read(cr, uid, ids, [])[0] max_amount = form.get('max_amount', False) and form.get('max_amount') or 0.0 power = form['power'] allow_write_off = form['allow_write_off'] reconciled = unreconciled = 0 if not form['account_ids']: raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile')) for account_id in form['account_ids']: params = (account_id,) if not allow_write_off: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) = 0.0 AND count(*)>0""" else: query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL AND state <> 'draft' GROUP BY partner_id HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0""" params.append(max_amount) # reconcile automatically all transactions from partners whose balance is 0 cr.execute(query, params) partner_ids = [id for (id,) in cr.fetchall()] for partner_id in partner_ids: cr.execute( "SELECT id " \ "FROM account_move_line " \ "WHERE account_id=%s " \ "AND partner_id=%s " \ "AND state <> 'draft' " \ "AND reconcile_id IS NULL", (account_id, partner_id)) line_ids = [id for (id,) in cr.fetchall()] if len(line_ids): reconciled += len(line_ids) if allow_write_off: move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context) else: move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={})
res[event.id]['register_current'] = len(reg_ids)
res[event.id]['register_current'] = number and number[0] or 0.0
def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft')
res[event.id]['register_prospect'] = len(reg_ids)
res[event.id]['register_prospect'] = number and number[0] or 0.0
def _get_register(self, cr, uid, ids, fields, args, context=None): """Get Confirm or uncofirm register value. @param ids: List of Event registration type's id @param fields: List of function fields(register_current and register_prospect). @param context: A standard dictionary for contextual values @return: Dictionary of function fields value. """ register_pool = self.pool.get('event.registration') res = {} for event in self.browse(cr, uid, ids, context): res[event.id] = {} for field in fields: res[event.id][field] = False state = [] if 'register_current' in fields: state += ['open', 'done'] if 'register_prospect' in fields: state.append('draft')
task_ids = map(lambda x : x.id, (filter(lambda x : x.state in ['open', 'draft', 'pending'] , phase.task_ids)))
task_ids = map(lambda x : x.id, (filter(lambda x : x.state in ['draft'] , phase.task_ids)))
def schedule_tasks(self, cr, uid, ids, context=None): """ Schedule the tasks according to resource available and priority. """ task_pool = self.pool.get('project.task') resource_pool = self.pool.get('resource.resource') resources_list = self.generate_resources(cr, uid, ids, context=context) return_msg = {} for phase in self.browse(cr, uid, ids, context=context): start_date = phase.date_start if not start_date and phase.project_id.date_start: start_date = phase.project_id.date_start if not start_date: start_date = datetime.now().strftime("%Y-%m-%d") resources = resources_list.get(phase.id, []) calendar_id = phase.project_id.resource_calendar_id.id task_ids = map(lambda x : x.id, (filter(lambda x : x.state in ['open', 'draft', 'pending'] , phase.task_ids))) if task_ids: task_pool.generate_schedule(cr, uid, task_ids, resources, calendar_id, start_date, context=context)
res = {} result_acc = []
def lines(self, form, ids=[], done=None):#, level=1): obj_account = self.pool.get('account.account') if not ids: ids = self.ids if not ids: return [] if not done: done={}
parents = ids
def lines(self, form, ids=[], done=None):#, level=1): obj_account = self.pool.get('account.account') if not ids: ids = self.ids if not ids: return [] if not done: done={}
accounts = obj_account.read(self.cr, self.uid, ids, ['type','code','name','debit','credit','balance','parent_id','level'], ctx) for account in accounts: if account['id'] in done: continue done[account['id']] = 1 res = { 'id': account['id'], 'type': account['type'], 'code': account['code'], 'name': account['name'], 'level': account['level'], 'debit': account['debit'], 'credit': account['credit'], 'balance': account['balance'], 'parent_id':account['parent_id'], 'bal_type':'', } self.sum_debit += account['debit'] self.sum_credit += account['credit'] if form['display_account'] == 'bal_movement': if res['credit'] > 0 or res['debit'] > 0 or res['balance'] > 0 : result_acc.append(res) elif form['display_account'] == 'bal_solde': if res['balance'] != 0: result_acc.append(res) else: result_acc.append(res) return result_acc
accounts = obj_account.read(self.cr, self.uid, ids, ['type','code','name','debit','credit','balance','parent_id','level','child_id'], ctx) for parent in parents: if parent in done: continue done[parent] = 1 _process_child(accounts,form['display_account'],parent) return self.result_acc
def lines(self, form, ids=[], done=None):#, level=1): obj_account = self.pool.get('account.account') if not ids: ids = self.ids if not ids: return [] if not done: done={}
return new_ids = isinstance(ids, (str, int, long)) and data[0] or data
return isinstance(ids, (str, int, long)) and data[0] or data
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): """ Read IR Model @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 IR Model’s IDs. @param context: A standard dictionary for contextual values """
last_date = datetime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1 task_obj=self.pool.get('project.task.work')
last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - relativedelta(days=1) task_obj = self.pool.get('project.task.work')
def _get_task_hours(self, cr, uid, ids, name,args,context): result = {} for record in self.browse(cr, uid, ids,context): last_date = datetime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1 task_obj=self.pool.get('project.task.work') task_ids = task_obj.search(cr, uid, [('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))]) tsk_hrs = task_obj.read(cr, uid, task_ids, ['hours','date','user_id']) total = 0.0 for hrs in tsk_hrs: total += hrs['hours'] result[record.id] = total return result
last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1 obj=self.pool.get('hr_timesheet_sheet.sheet.day')
last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - relativedelta(days=1) obj = self.pool.get('hr_timesheet_sheet.sheet.day')
def get_hrs_timesheet(self, cr, uid, ids, name,args,context): result = {} sum = 0.0 for record in self.browse(cr, uid, ids, context): last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1 obj=self.pool.get('hr_timesheet_sheet.sheet.day') sheet_ids = obj.search(cr, uid, [('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))]) data_days = obj.read(cr, uid, sheet_ids, ['name','sheet_id.user_id','total_attendance']) total = 0.0 for day_attendance in data_days: total += day_attendance['total_attendance'] result[record.id] = total return result
data = self.read(cr, uid, ids, [], context)[0] line_ids= data['entries']
payment_obj = self.pool.get('payment.line') if context is None: context = {} data = self.read(cr, uid, ids, [])[0] line_ids = data['entries']
def create_payment(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line')
payment = order_obj.browse(cr, uid, data['active_id'], context=context)
payment = order_obj.browse(cr, uid, context['active_id'], context=context)
def create_payment(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line')
line2bank = pool.get('account.move.line').line2bank(cr, uid, line_ids, t, context)
line2bank = line_obj.line2bank(cr, uid, line_ids, t, context)
def create_payment(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line')
pool.get('payment.line').create(cr, uid,{
payment_obj.create(cr, uid,{
def create_payment(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line')
return {}
return {'nodestroy':True,}
def create_payment(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line')
if context is None: context = {}
def search_entries(self, cr, uid, ids, context=None): order_obj = self.pool.get('payment.order') line_obj = self.pool.get('account.move.line') mod_obj = self.pool.get('ir.model.data')
last_date = datetime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1
last_date = datetime.strptime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1
def _get_task_hours(self, cr, uid, ids, name,args,context): result = {} for record in self.browse(cr, uid, ids,context): last_date = datetime(record.name, '%Y-%m-%d') + relativedelta(months=1) - 1 task_obj=self.pool.get('project.task.work') task_ids = task_obj.search(cr, uid, [('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))]) tsk_hrs = task_obj.read(cr, uid, task_ids, ['hours','date','user_id']) total = 0.0 for hrs in tsk_hrs: total += hrs['hours'] result[record.id] = total return result
'base_code_id': fields.many2one('account.tax.code', 'Base Code', help="Use this code for the VAT declaration."), 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="Use this code for the VAT declaration."),
'base_code_id': fields.many2one('account.tax.code', 'Account Base Code', help="Use this code for the VAT declaration."), 'tax_code_id': fields.many2one('account.tax.code', 'Account Tax Code', help="Use this code for the VAT declaration."),
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context)
res_id = model_pool.message_new(cr, uid, msg, context)
res_id = model_pool.message_new(cr, uid, msg, context)fetchmail/fetchmail.py
logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_update is not define in model %s' % (model_pool._name))
fp = os.popen('ping www.google.com -c 1 -w 5',"r") if not fp.read(): logger.notifyChannel('imap', netsvc.LOG_WARNING, 'lost internet connection !')
def fetch_mail(self, cr, uid, ids, context={}):
date_planned = (date_planned - relativedelta(company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
date_planned = (date_planned - timedelta(days=company.security_lead)).strftime('%Y-%m-%d %H:%M:%S')
def action_ship_create(self, cr, uid, ids, *args): picking_id = False company = self.pool.get('res.users').browse(cr, uid, uid).company_id for order in self.browse(cr, uid, ids, context={}): proc_ids = [] output_id = order.shop_id.warehouse_id.lot_output_id.id picking_id = False for line in order.order_line: proc_id = False date_planned = datetime.now() + relativedelta(days=line.delay or 0.0) date_planned = (date_planned - relativedelta(company.security_lead)).strftime('%Y-%m-%d %H:%M:%S') if line.state == 'done': continue move_id = False if line.product_id and line.product_id.product_tmpl_id.type in ('product', 'consu'): location_id = order.shop_id.warehouse_id.lot_stock_id.id if not picking_id: loc_dest_id = order.partner_id.property_stock_customer.id pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out') picking_id = self.pool.get('stock.picking').create(cr, uid, { 'name': pick_name, 'origin': order.name, 'type': 'out', 'state': 'auto', 'move_type': order.picking_policy, 'sale_id': order.id, 'address_id': order.partner_shipping_id.id, 'note': order.note, 'invoice_state': (order.order_policy=='picking' and '2binvoiced') or 'none', 'company_id': order.company_id.id, }) move_id = self.pool.get('stock.move').create(cr, uid, { 'name': line.name[:64], 'picking_id': picking_id, 'product_id': line.product_id.id, 'date_planned': date_planned, 'date_expected': date_planned, 'product_qty': line.product_uom_qty, 'product_uom': line.product_uom.id, 'product_uos_qty': line.product_uos_qty, 'product_uos': (line.product_uos and line.product_uos.id)\ or line.product_uom.id, 'product_packaging': line.product_packaging.id, 'address_id': line.address_allotment_id.id or order.partner_shipping_id.id, 'location_id': location_id, 'location_dest_id': output_id, 'sale_line_id': line.id, 'tracking_id': False, 'state': 'draft', #'state': 'waiting', 'note': line.notes, 'company_id': order.company_id.id, }) if line.product_id: proc_id = self.pool.get('procurement.order').create(cr, uid, { 'name': line.name, 'origin': order.name, 'date_planned': date_planned, 'product_id': line.product_id.id, 'product_qty': line.product_uom_qty, 'product_uom': line.product_uom.id, 'product_uos_qty': (line.product_uos and line.product_uos_qty)\ or line.product_uom_qty, 'product_uos': (line.product_uos and line.product_uos.id)\ or line.product_uom.id, 'location_id': order.shop_id.warehouse_id.lot_stock_id.id, 'procure_method': line.type, 'move_id': move_id, 'property_ids': [(6, 0, [x.id for x in line.property_ids])], 'company_id': order.company_id.id, }) proc_ids.append(proc_id) self.pool.get('sale.order.line').write(cr, uid, [line.id], {'procurement_id': proc_id})
"AND reconcile_id IS NULL " \
" " + RECONCILE_TAG + " "\
def _get_intial_balance(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': move_state = ['posted']
'am_out': fields.boolean('Controle for Output Operations'), 'disc_controle': fields.boolean('Discount Controle '),
'am_out': fields.boolean('Control for Output Operations'), 'disc_controle': fields.boolean('Discount Control'),
def _scan_product(self, cr, uid, ean, qty, order): # search pricelist_id product_obj=self.pool.get('product.product') pricelist_id = self.pool.get('pos.order').read(cr, uid, [order], ['pricelist_id'] ) if not pricelist_id: return False
LOG_DEBUG2 = 'debug2'
def log(lvl,msg): netsvc.Logger().notifyChannel("index",lvl,msg)
_columns = { 'year': fields.char('Year', size='4', readonly=True, select=1), 'canceled_number': fields.integer('Canceled', readonly=True), 'waiting_number': fields.integer('Waiting', readonly=True), 'invoiced_number': fields.integer('Invoiced', readonly=True), 'paid_number': fields.integer('Paid', readonly=True), 'canceled_amount': fields.float('Canceled', digits=(16, 2), readonly=True), 'waiting_amount': fields.float('Waiting', digits=(16, 2), readonly=True), 'invoiced_amount': fields.float('Invoiced', digits=(16, 2), readonly=True), 'paid_amount': fields.float('Paid', digits=(16, 2), readonly=True), 'currency': fields.many2one('res.currency', 'Currency', readonly=True, select=2), } def init(self, cr): '''Create the view''' cr.execute(""" CREATE OR REPLACE VIEW report_partner_member_year AS ( SELECT MIN(id) AS id, COUNT(ncanceled) as canceled_number, COUNT(npaid) as paid_number, COUNT(ninvoiced) as invoiced_number, COUNT(nwaiting) as waiting_number, SUM(acanceled) as canceled_amount, SUM(apaid) as paid_amount, SUM(ainvoiced) as invoiced_amount, SUM(awaiting) as waiting_amount, year, currency FROM (SELECT CASE WHEN ai.state = 'cancel' THEN ml.id END AS ncanceled, CASE WHEN ai.state = 'paid' THEN ml.id END AS npaid, CASE WHEN ai.state = 'open' THEN ml.id END AS ninvoiced, CASE WHEN (ai.state = 'draft' OR ai.state = 'proforma') THEN ml.id END AS nwaiting, CASE WHEN ai.state = 'cancel' THEN SUM(ail.price_unit * ail.quantity * (1 - ail.discount / 100)) ELSE 0 END AS acanceled, CASE WHEN ai.state = 'paid' THEN SUM(ail.price_unit * ail.quantity * (1 - ail.discount / 100)) ELSE 0 END AS apaid, CASE WHEN ai.state = 'open' THEN SUM(ail.price_unit * ail.quantity * (1 - ail.discount / 100)) ELSE 0 END AS ainvoiced, CASE WHEN (ai.state = 'draft' OR ai.state = 'proforma') THEN SUM(ail.price_unit * ail.quantity * (1 - ail.discount / 100)) ELSE 0 END AS awaiting, TO_CHAR(ml.date_from, 'YYYY') AS year, ai.currency_id AS currency, MIN(ml.id) AS id FROM membership_membership_line ml JOIN (account_invoice_line ail LEFT JOIN account_invoice ai ON (ail.invoice_id = ai.id)) ON (ml.account_invoice_line = ail.id) JOIN res_partner p ON (ml.partner = p.id) GROUP BY TO_CHAR(ml.date_from, 'YYYY'), ai.state, ai.currency_id, ml.id) AS foo GROUP BY year, currency) """) ReportPartnerMemberYear() class ReportPartnerMemberYearNew(osv.osv): '''New Membership by Years''' _name = 'report.partner_member.year_new' _description = __doc__ _auto = False _rec_name = 'year'
def init(self, cr): '''Create the view''' cr.execute("""
case_val = case_obj.browse(cr, uid, alarmdata.get('id'), context)[0] for att in case_val.attendees:
case_val = case_obj.browse(cr, uid, alarmdata.get('id'), context) for att in case_val.attendee_ids:
def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, \ context=None): if not context: context = {} cr.execute('select c.id as id, crm_case.date as date, alarm.id as alarm_id, alarm.name as name,\ alarm.trigger_interval, alarm.trigger_duration, alarm.trigger_related, \ alarm.trigger_occurs from crm_meeting c \ join crm_case on c.inherit_case_id = crm_case.id \ join crm_caldav_alarm alarm on (alarm.id=c.alarm_id) \ where alarm_id is not null and alarm.active=True') case_with_alarm = cr.dictfetchall() case_obj = self.pool.get('crm.meeting') attendee_obj = self.pool.get('crm.caldav.attendee') mail_to = [] for alarmdata in case_with_alarm: dtstart = datetime.datetime.strptime(alarmdata['date'], "%Y-%m-%d %H:%M:%S") if alarmdata['trigger_interval'] == 'DAYS': delta = datetime.timedelta(days=alarmdata['trigger_duration']) if alarmdata['trigger_interval'] == 'HOURS': delta = datetime.timedelta(hours=alarmdata['trigger_duration']) if alarmdata['trigger_interval'] == 'MINUTES': delta = datetime.timedelta(minutes=alarmdata['trigger_duration']) alarm_time = dtstart + (alarmdata['trigger_occurs']== 'AFTER' and delta or -delta) if datetime.datetime.now() >= alarm_time: case_val = case_obj.browse(cr, uid, alarmdata.get('id'), context)[0] for att in case_val.attendees: if att.cn.rsplit(': ')[-1]: mail_to.append(att.cn.rsplit(': ')[-1]) if mail_to: sub = 'Event Reminder for ' + case_val.name or '' body = (case_val.name or '')+ '\n\t' + (case_val.description or '') + '\n\nEvent time: ' \ +(case_val.date) + '\n\nLocation: ' + (case_val.location or '') + \ '\n\nMembers Details: ' + '\n'.join(mail_to) tools.email_send( case_val.user_id.address_id.email, mail_to, sub, body ) cr.execute('update crm_caldav_alarm set active=False\ where id = %s' % alarmdata['alarm_id']) cr.commit() return True
ls = common.caldav_id2real_id(caldav_id)
ls = common.caldav_id2real_id(id)
def unlink(self, cr, uid, ids, context=None): for id in ids: ls = common.caldav_id2real_id(caldav_id) if not isinstance(ls, (str, int, long)) and len(ls) >= 2: date_new = ls[1] for record in self.read(cr, uid, [common.caldav_id2real_id(id)], \ ['date', 'rrule', 'exdate']): if record['rrule']: exdate = (record['exdate'] and (record['exdate'] + ',') or '') + \ ''.join((re.compile('\d')).findall(date_new)) + 'Z' if record['date'] == date_new: self.write(cr, uid, [common.caldav_id2real_id(id)], {'exdate': exdate}) else: ids = map(lambda x: common.caldav_id2real_id(x), ids) return super(crm_meeting, self).unlink(cr, uid, common.caldav_id2real_id(ids)) else: return super(crm_meeting, self).unlink(cr, uid, ids)
'availability': fields.selection([('free', 'Free'), \ ('busy', 'Busy'), ('both', 'Both')], 'User Avaliability') } _defaults = { 'availability': lambda *x: 'free', }
}
def _get_user_avail(self, cr, uid, ids, name, args, context=None): res={} if not context or not context.get('model'): return {} else: model = context.get('model') obj = self.pool.get(model) event_obj = obj.browse(cr, uid, context['active_id']) event_start = event_obj.date event_end = datetime.datetime.strptime(event_obj.date, "%Y-%m-%d %H:%M:%S") \ + datetime.timedelta(hours=event_obj.duration) for id in ids: datas = self.browse(cr, uid, id) cr.execute("""SELECT c.date as start, (c.date::timestamp \ + c.duration * interval '1 hour') as end \ from crm_meeting m \ join crm_case c on (c.id=m.inherit_case_id)\ where c.user_id = %s and m.id not in (""" % (datas['id']) + str(context['active_id']) +")") dates = cr.dictfetchall() overlaps = False # check event time for date in dates: start = date['start'] end = date['end'] cr.execute("SELECT (timestamp '%s', timestamp '%s') OVERLAPS\ (timestamp '%s', timestamp '%s')" % (event_start, event_end, start, end)) over = cr.fetchone()[0] if over: overlaps = True
datas = self.read(cr, uid, ids)[0] if not context or not context.get('model') or not datas.get('users'): return {} else: model = context.get('model') obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) user_obj = self.pool.get('res.users') attendee_obj = self.pool.get('crm.caldav.attendee') for user_id in datas.get('users', []): user = user_obj.browse(cr, uid, user_id) if not user.address_id.email: raise osv.except_osv(_('Error!'), \ ("User does not have an email Address")) attendee_id = attendee_obj.create(cr, uid, {'user_id': user_id,\ 'cn': user.name + ':MAILTO:' + user.address_id.email}) obj.write(cr, uid, res_obj.id, {'attendee_ids': [(6, 0, [attendee_id])]})
def do_invite(self, cr, uid, ids, context={}): #TODO: Add attendee return {}
res = {'value' : {'code' : '%s - %03d' % (parent['code'] or '', numchild + 1),}}
res = {'value' : {}}
def on_change_parent(self, cr, uid, id, parent_id): if not parent_id: return {} parent = self.read(cr, uid, [parent_id], ['partner_id','code'])[0] childs = self.search(cr, uid, [('parent_id', '=', parent_id)]) numchild = len(childs) if parent['partner_id']: partner = parent['partner_id'][0] else: partner = False res = {'value' : {'code' : '%s - %03d' % (parent['code'] or '', numchild + 1),}} if partner: res['value']['partner_id'] = partner return res
value = acct_obj.search(cr, uid, [('type', 'in',('sale','sale_refund') )])
value = acct_obj.search(cr, uid, [('type', 'in',('sale','purchase_refund') )])
def _get_journal_id(self, cr, uid, context=None): if context is None: context = {}
value = acct_obj.search(cr, uid, [('type', 'in',('purchase','purchase_refund') )])
value = acct_obj.search(cr, uid, [('type', 'in',('purchase','sale_refund') )])
def _get_journal_id(self, cr, uid, context=None): if context is None: context = {}
cr.execute("select m.id, m.rrule, m.date, m.date_deadline, \
cr.execute("select m.id, m.rrule, m.date, m.date_deadline, m.duration, \
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): """Gives virtual event ids for recurring events based on value of Recurrence Rule This method gives ids of dates that comes between start date and end date of calendar views @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 """
report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml', parser=journal_print, header=False)
def _get_account(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).company_id.name return super(journal_print ,self)._get_account(data) 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 _print_data(self, data): if data['model']=='account.journal.period': return self.pool.get('account.journal.period').browse(self.cr, self.uid, data['id']).journal_id.currency or False return data['form']['amount_currency'] report_sxw.report_sxw('report.account.central.journal', 'account.journal.period', 'addons/account/report/central_journal.rml', parser=journal_print, header='internal')
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()
return super(event_event, self)._check_recursion(self, cr, uid, ids)
return super(event_event, self)._check_recursion(cr, uid, ids)
def _check_recursion(self, cr, uid, ids): return super(event_event, self)._check_recursion(self, cr, uid, ids)
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'):
date = time.strptime(vals['date'], '%Y-%m-%d') if not (date >= time.strptime(period.date_start,'%Y-%m-%d') and date <= time.strptime(period.date_stop,'%Y-%m-%d') ):
def check_date(self, cr, uid, vals, context=None, check=True): if not context: 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 not 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
'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Real Entry'),
'move_ids': fields.related('move_id','line_id', type='many2many', relation='account.move.line', string='Journal Items', readonly=True, states={'draft':[('readonly',False)]}),
def _get_currency(self, cr, uid, context): user = self.pool.get('res.users').browse(cr, uid, uid) if user.company_id: return user.company_id.currency_id.id else: return self.pool.get('res.currency').search(cr, uid, [('rate','=',1.0)])[0]
val = {'invoiced': True}
for line in order.order_line: if line.state == 'exception': self.pool.get('sale.order.line').write(cr, uid, [line.id], {'state': 'confirmed'}, context=context)
def action_invoice_end(self, cr, uid, ids, context=None): if context is None: context = {} for order in self.browse(cr, uid, ids, context=context): val = {'invoiced': True} if order.state == 'invoice_except': val['state'] = 'progress'
val['state'] = 'progress' for line in order.order_line: towrite = [] if line.state == 'exception': towrite.append(line.id) if towrite: self.pool.get('sale.order.line').write(cr, uid, towrite, {'state': 'confirmed'}, context=context) self.write(cr, uid, [order.id], val)
self.write(cr, uid, [order.id], {'state' : 'progress'}, context=context)
def action_invoice_end(self, cr, uid, ids, context=None): if context is None: context = {} for order in self.browse(cr, uid, ids, context=context): val = {'invoiced': True} if order.state == 'invoice_except': val['state'] = 'progress'
cr.execute( "UPDATE account_move_line "\ "SET followup_line_id=%s, followup_date=%s "\ "WHERE id=%s", (to_update[id], data['form']['date'], int(id),))
if to_update[id]['partner_id'] in data['form']['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'], data['form']['date'], int(id),))
def _update_partners(self, cr, uid, data, context): to_update = data['form']['to_update'] for id in to_update.keys(): cr.execute( "UPDATE account_move_line "\ "SET followup_line_id=%s, followup_date=%s "\ "WHERE id=%s", (to_update[id], data['form']['date'], int(id),)) return {}
to_update[str(id)] = fups[followup_line_id][1]
to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': partner_id}
def _get_partners(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) cr.execute( "SELECT l.partner_id, l.followup_line_id,l.date_maturity, l.date, l.id "\ "FROM account_move_line AS l "\ "LEFT JOIN account_account AS a "\ "ON (l.account_id=a.id) "\ "WHERE (l.reconcile_id IS NULL) "\ "AND (a.type='receivable') "\ "AND (l.state<>'draft') "\ "AND (l.partner_id is NOT NULL) "\ "AND (a.active) "\ "ORDER BY l.date") move_lines = cr.fetchall() old = None fups = {} fup_id = data['form']['followup_id']
_order = "sequence"
def unlink(self, cr, uid, ids, *args, **kwargs): for proj in self.browse(cr, uid, ids): if proj.tasks: raise osv.except_osv(_('Operation Not Permitted !'), _('You can not delete a project with tasks. I suggest you to deactivate it.')) return super(project, self).unlink(cr, uid, ids, *args, **kwargs)
'date_from': fields.function(_product_margin, method=True, type='date', string='From Date', multi=True), 'date_to': fields.function(_product_margin, method=True, type='date', string='To Date', multi=True),
'date_from': fields.function(_product_margin, method=True, type='date', string='From Date', multi='product_margin'), 'date_to': fields.function(_product_margin, method=True, type='date', string='To Date', multi='product_margin'),
def _product_margin(self, cr, uid, ids, field_names, arg, context=None): res = {} if context is None: context = {} for val in self.browse(cr, uid, ids,context=context): res[val.id] = {} date_from = context.get('date_from', time.strftime('%Y-01-01')) date_to = context.get('date_to', time.strftime('%Y-12-31')) invoice_state = context.get('invoice_state', 'open_paid') if 'date_from' in field_names: res[val.id]['date_from']=date_from if 'date_to' in field_names: res[val.id]['date_to']=date_to if 'invoice_state' in field_names: res[val.id]['invoice_state']=invoice_state invoice_types = () states = () if invoice_state=='paid': states=('paid',) elif invoice_state=='open_paid': states=('open','paid') elif invoice_state=='draft_open_paid': states=('draft','open','paid')
('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid') ], string='Invoice State',multi=True, readonly=True), 'sale_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='sale',help="Avg. Price in Customer Invoices)"), 'purchase_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='purchase',help="Avg. Price in Supplier Invoices "), 'sale_num_invoiced' : fields.function(_product_margin, method=True, type='float', string=' 'purchase_num_invoiced' : fields.function(_product_margin, method=True, type='float', string=' 'sales_gap' : fields.function(_product_margin, method=True, type='float', string='Sales Gap', multi='sale',help="Expected Sale - Turn Over"), 'purchase_gap' : fields.function(_product_margin, method=True, type='float', string='Purchase Gap', multi='purchase',help="Normal Cost - Total Cost"), 'turnover' : fields.function(_product_margin, method=True, type='float', string='Turnover' ,multi='sale',help="Sum of Multification of Invoice price and quantity of Customer Invoices"), 'total_cost' : fields.function(_product_margin, method=True, type='float', string='Total Cost', multi='purchase',help="Sum of Multification of Invoice price and quantity of Supplier Invoices "), 'sale_expected' : fields.function(_product_margin, method=True, type='float', string='Expected Sale', multi='sale',help="Sum of Multification of Sale Catalog price and quantity of Customer Invoices"), 'normal_cost' : fields.function(_product_margin, method=True, type='float', string='Normal Cost', multi='purchase',help="Sum of Multification of Cost price and quantity of Supplier Invoices"), 'total_margin' : fields.function(_product_margin, method=True, type='float', string='Total Margin', multi='total',help="Turnorder - Standard price"), 'expected_margin' : fields.function(_product_margin, method=True, type='float', string='Expected Margin', multi='total',help="Expected Sale - Normal Cost"), 'total_margin_rate' : fields.function(_product_margin, method=True, type='float', string='Total Margin (%)', multi='margin',help="Total margin * 100 / Turnover"), 'expected_margin_rate' : fields.function(_product_margin, method=True, type='float', string='Expected Margin (%)', multi='margin',help="Expected margin * 100 / Expected Sale"),
('paid','Paid'),('open_paid','Open and Paid'),('draft_open_paid','Draft, Open and Paid') ], string='Invoice State',multi='product_margin', readonly=True), 'sale_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='product_margin', help="Avg. Price in Customer Invoices)"), 'purchase_avg_price' : fields.function(_product_margin, method=True, type='float', string='Avg. Unit Price', multi='product_margin', help="Avg. Price in Supplier Invoices "), 'sale_num_invoiced' : fields.function(_product_margin, method=True, type='float', string=' help="Sum of Quantity in Customer Invoices"), 'purchase_num_invoiced' : fields.function(_product_margin, method=True, type='float', string=' help="Sum of Quantity in Supplier Invoices"), 'sales_gap' : fields.function(_product_margin, method=True, type='float', string='Sales Gap', multi='product_margin', help="Expected Sale - Turn Over"), 'purchase_gap' : fields.function(_product_margin, method=True, type='float', string='Purchase Gap', multi='product_margin', help="Normal Cost - Total Cost"), 'turnover' : fields.function(_product_margin, method=True, type='float', string='Turnover' ,multi='product_margin', help="Sum of Multification of Invoice price and quantity of Customer Invoices"), 'total_cost' : fields.function(_product_margin, method=True, type='float', string='Total Cost', multi='product_margin', help="Sum of Multification of Invoice price and quantity of Supplier Invoices "), 'sale_expected' : fields.function(_product_margin, method=True, type='float', string='Expected Sale', multi='product_margin', help="Sum of Multification of Sale Catalog price and quantity of Customer Invoices"), 'normal_cost' : fields.function(_product_margin, method=True, type='float', string='Normal Cost', multi='product_margin', help="Sum of Multification of Cost price and quantity of Supplier Invoices"), 'total_margin' : fields.function(_product_margin, method=True, type='float', string='Total Margin', multi='product_margin', help="Turnorder - Standard price"), 'expected_margin' : fields.function(_product_margin, method=True, type='float', string='Expected Margin', multi='product_margin', help="Expected Sale - Normal Cost"), 'total_margin_rate' : fields.function(_product_margin, method=True, type='float', string='Total Margin (%)', multi='product_margin', help="Total margin * 100 / Turnover"), 'expected_margin_rate' : fields.function(_product_margin, method=True, type='float', string='Expected Margin (%)', multi='product_margin', help="Expected margin * 100 / Expected Sale"),
def _product_margin(self, cr, uid, ids, field_names, arg, context=None): res = {} if context is None: context = {} for val in self.browse(cr, uid, ids,context=context): res[val.id] = {} date_from = context.get('date_from', time.strftime('%Y-01-01')) date_to = context.get('date_to', time.strftime('%Y-12-31')) invoice_state = context.get('invoice_state', 'open_paid') if 'date_from' in field_names: res[val.id]['date_from']=date_from if 'date_to' in field_names: res[val.id]['date_to']=date_to if 'invoice_state' in field_names: res[val.id]['invoice_state']=invoice_state invoice_types = () states = () if invoice_state=='paid': states=('paid',) elif invoice_state=='open_paid': states=('open','paid') elif invoice_state=='draft_open_paid': states=('draft','open','paid')
'account_id': a,
'account_id': a.id,
def inv_line_create(self, cr, uid, a, ol): return (0, False, { 'name': ol.name, 'account_id': a, 'price_unit': ol.price_unit or 0.0, 'quantity': ol.product_qty, 'product_id': ol.product_id.id or False, 'uos_id': ol.product_uom.id or False, 'invoice_line_tax_id': [(6, 0, [x.id for x in ol.taxes_id])], 'account_analytic_id': ol.account_analytic_id.id, })