rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
WHERE pur.project_id=pp.id and pt.project_id=pp.id and pp.category_id=aaa.id
WHERE pur.project_id=pp.id and pt.project_id=pp.id and pp.category_id=aaa.id AND pur.uid != aaa.user_id
def init(self, cr): tools.sql.drop_view_if_exists(cr, 'project_vs_hours') cr.execute(""" CREATE or REPLACE view project_vs_hours as ( select min(pt.id) as id, aaa.user_id as uid, aaa.name as project, aaa.state, sum(pt.remaining_hours) as remaining_hours, sum(pt.planned_hours) as planned_hours, sum(pt.total_hours) as total_hours FROM project_project as pp, account_analytic_account as aaa, project_task as pt WHERE aaa.id=pp.category_id and pt.project_id=pp.id and pp.category_id=aaa.id GROUP BY aaa.user_id,aaa.state,aaa.name UNION All SELECT min(pt.id) as id, pur.uid as uid, aaa.name as project, aaa.state, sum(pt.remaining_hours) as remaining_hours, sum(pt.planned_hours) as planned_hours, sum(pt.total_hours) as total_hours FROM project_project as pp, project_user_rel as pur, account_analytic_account as aaa, project_task as pt WHERE pur.project_id=pp.id and pt.project_id=pp.id and pp.category_id=aaa.id GROUP BY pur.uid,aaa.state,aaa.name ) """)
delay = partner_rec and partner_rec.delay or False newdate = newdate -(delay or datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
delay = partner_rec and partner_rec.delay or 0.0 newdate = newdate -(delay and relativedelta(days=delay) or datetime.strptime(tender.date_start, '%Y-%m-%d %H:%M:%S') )
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders .
cur = user_id.company_id.currency_id.name amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur); return amt_en
return amount_to_text_en.amount_to_text(amount, 'en', user_id.company_id.currency_id.name)
def convert(self, amount): user_id = self.pool.get('res.users').browse(self.cr, self.user, [self.user])[0] cur = user_id.company_id.currency_id.name amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur); return amt_en
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped'),
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped', readonly=True),
def _check_product_lot(self, cr, uid, ids, context=None): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids, context=context): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
lines = end_lines = self._get_cash_close_box_lines(cr, uid, [], context) vals.update({ 'ending_details_ids':lines })
if self.pool.get('account.journal').browse(cr, uid, vals['journal_id']).type == 'cash': lines = end_lines = self._get_cash_close_box_lines(cr, uid, [], context) vals.update({ 'ending_details_ids':lines }) else: vals.update({ 'ending_details_ids':False, 'starting_details_ids':False })
def create(self, cr, uid, vals, context=None): company_id = vals and vals.get('company_id',False) if company_id: sql = [ ('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open') ] open_jrnl = self.search(cr, uid, sql) if open_jrnl: raise osv.except_osv('Error', _('You can not have two open register for the same journal'))
class res_users(osv.osv): _name = 'res.users' _inherit = 'res.users' def create(self, cr, uid, data, context=None): if context is None: context = {} user_id = super(res_users, self).create(cr, uid, data, context) data_obj = self.pool.get('ir.model.data') try: data_id = data_obj._get_id(cr, uid, 'product', 'ir_ui_view_sc_product0') view_id = data_obj.browse(cr, uid, data_id, context=context).res_id copy_id = self.pool.get('ir.ui.view_sc').copy(cr, uid, view_id, default = { 'user_id': user_id}, context=context) except ValueError: logging.getLogger('orm').warning('Skipped Products shortcut for user "%s"', data.get('name','<new')) return user_id res_users()
def price_get(self, cr, uid, supplier_ids, product_id, product_qty=1, context=None): """ Calculate price from supplier pricelist. @param supplier_ids: Ids of res.partner object. @param product_id: Id of product. @param product_qty: specify quantity to purchase. """ if not context: context = {} if type(supplier_ids) in (int,long,): supplier_ids = [supplier_ids] res = {} product_pool = self.pool.get('product.product') partner_pool = self.pool.get('res.partner') pricelist_pool = self.pool.get('product.pricelist') currency_pool = self.pool.get('res.currency') currency_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id for supplier in partner_pool.browse(cr, uid, supplier_ids, context=context): # Compute price from standard price of product price = product_pool.price_get(cr, uid, [product_id], 'standard_price')[product_id]
context['active_id'],
context['template_id'],
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: Open ERP Context """ return self.pool.get('email.template').read( cursor, user, context['active_id'], ['object_name'], context)['object_name']
'ref_template': lambda self, cr, uid, ctx:ctx['active_id'],
'ref_template': lambda self, cr, uid, ctx:ctx['template_id'],
def _default_model(self, cursor, user, context=None): """ Returns the default value for model field @param cursor: Database Cursor @param user: ID of current user @param context: Open ERP Context """ return self.pool.get('email.template').read( cursor, user, context['active_id'], ['object_name'], context)['object_name']
template = self.pool.get('email.template').browse(cr, uid, context['active_id'], context)
template = self.pool.get('email.template').browse(cr, uid, context['template_id'], context)
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None): if context is None: context = {} if not rel_model_ref: return {} vals = {} if context == {}: context = self.context template = self.pool.get('email.template').browse(cr, uid, context['active_id'], context) #Search translated template lang = get_value(cr, uid, rel_model_ref, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.pool.get('email.template').browse(cr, uid, context['active_id'], ctx) vals['to'] = get_value(cr, uid, rel_model_ref, template.def_to, template, context) vals['cc'] = get_value(cr, uid, rel_model_ref, template.def_cc, template, context) vals['bcc'] = get_value(cr, uid, rel_model_ref, template.def_bcc, template, context) vals['subject'] = get_value(cr, uid, rel_model_ref, template.def_subject, template, context) vals['body_text'] = get_value(cr, uid, rel_model_ref, template.def_body_text, template, context) vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context) vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context) return {'value':vals}
template = self.pool.get('email.template').browse(cr, uid, context['active_id'], ctx)
template = self.pool.get('email.template').browse(cr, uid, context['template_id'], ctx)
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None): if context is None: context = {} if not rel_model_ref: return {} vals = {} if context == {}: context = self.context template = self.pool.get('email.template').browse(cr, uid, context['active_id'], context) #Search translated template lang = get_value(cr, uid, rel_model_ref, template.lang, template, context) if lang: ctx = context.copy() ctx.update({'lang':lang}) template = self.pool.get('email.template').browse(cr, uid, context['active_id'], ctx) vals['to'] = get_value(cr, uid, rel_model_ref, template.def_to, template, context) vals['cc'] = get_value(cr, uid, rel_model_ref, template.def_cc, template, context) vals['bcc'] = get_value(cr, uid, rel_model_ref, template.def_bcc, template, context) vals['subject'] = get_value(cr, uid, rel_model_ref, template.def_subject, template, context) vals['body_text'] = get_value(cr, uid, rel_model_ref, template.def_body_text, template, context) vals['body_html'] = get_value(cr, uid, rel_model_ref, template.def_body_html, template, context) vals['report'] = get_value(cr, uid, rel_model_ref, template.file_name, template, context) return {'value':vals}
domain += ['|',('user_id','=',uid)]
domain += ['|',('user_id','=',user_id)]
def account_get(self, cr, uid, product_id=None, partner_id=None, user_id=None, date=None, context={}): domain = [] if product_id: domain += ['|',('product_id','=',product_id)] domain += [('product_id','=',False)] if partner_id: domain += ['|',('partner_id','=',partner_id)] domain += [('partner_id','=',False)] if user_id: domain += ['|',('user_id','=',uid)] domain += [('user_id','=',False)] if date: domain += ['|',('date_start','<=',date),('date_start','=',False)] domain += ['|',('date_stop','>=',date),('date_stop','=',False)] best_index = -1 res = False for rec in self.browse(cr, uid, self.search(cr, uid, domain, context=context), context=context): index = 0 if rec.product_id: index+=1 if rec.partner_id: index+=1 if rec.user_id: index+=1 if rec.date_start: index+=1 if rec.date_stop: index+=1 if index>best_index: res = rec best_index = index return res
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None):
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit)
total_debit = currency_pool.compute(cr, uid, currency_id, company_currency, total_debit, context=context_multi_currency)
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit)
total_credit = currency_pool.compute(cr, uid, currency_id, company_currency, total_credit, context=context_multi_currency)
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
'amount_original':currency_pool.compute(cr, uid, company_currency, currency_id, original_amount),
'amount_original':currency_pool.compute(cr, uid, company_currency, currency_id, original_amount, context=context_multi_currency),
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
'amount_unreconciled':currency_pool.compute(cr, uid, company_currency, currency_id, line.amount_unreconciled)
'amount_unreconciled':currency_pool.compute(cr, uid, company_currency, currency_id, line.amount_unreconciled, context=context_multi_currency)
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount)
rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount, context=context_multi_currency)
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, context=None): """price Returns a dict that contains new values and context
def onchange_date(self, cr, user, ids, date, context=None):
def onchange_date(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=None):
def onchange_date(self, cr, user, ids, date, context=None): """ @param date: latest value from user input for field date @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ period_pool = self.pool.get('account.period') pids = period_pool.search(cr, user, [('date_start', '<=', date), ('date_stop', '>=', date)]) if not pids: return {} return { 'value':{ 'period_id':pids[0] } }
pids = period_pool.search(cr, user, [('date_start', '<=', date), ('date_stop', '>=', date)]) if not pids: return {} return { 'value':{ 'period_id':pids[0] } }
res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context) pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)]) if pids: res['value'].update({'period_id':pids[0]}) return res
def onchange_date(self, cr, user, ids, date, context=None): """ @param date: latest value from user input for field date @param args: other arguments @param context: context arguments, like lang, time zone @return: Returns a dict which contains new values, and context """ period_pool = self.pool.get('account.period') pids = period_pool.search(cr, user, [('date_start', '<=', date), ('date_stop', '>=', date)]) if not pids: return {} return { 'value':{ 'period_id':pids[0] } }
credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount)
credit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
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
debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount)
debit = currency_pool.compute(cr, uid, current_currency, company_currency, inv.amount, context=context_multi_currency)
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
line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount)
line_total = line_total - currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
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
line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount)
line_total = line_total + currency_pool.compute(cr, uid, inv.currency_id.id, company_currency, inv.tax_amount, context=context_multi_currency)
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
amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount)
amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context_multi_currency)
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
'amount_currency': company_currency <> current_currency and currency_pool.compute(cr, uid, company_currency, current_currency, diff * -1) or 0.0,
'amount_currency': company_currency <> current_currency and currency_pool.compute(cr, uid, company_currency, current_currency, diff * -1, context=context_multi_currency) or 0.0,
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
'partner_id': hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False,
'partner_id': partner_id,
def history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \ email_from=False, message_id=False, references=None, attach=None, email_cc=None, \ email_bcc=None, email_date=None, context=None): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param cases: a browse record list @param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used @param history: Value True/False, If True it makes entry in case History otherwise in Case Log @param email: Email-To / Recipient address @param email_from: Email From / Sender address if any @param email_cc: Comma-Separated list of Carbon Copy Emails To addresse if any @param email_bcc: Comma-Separated list of Blind Carbon Copy Emails To addresses if any @param email_date: Email Date string if different from now, in server Timezone @param details: Description, Details of case history if any @param atach: Attachment sent in email @param context: A standard dictionary for contextual values""" if context is None: context = {} if attach is None: attach = []
val = 0.0
val = val1 = 0.0
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') res = {} for order in self.browse(cr, uid, ids, context=context): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } val = 0.0 cur = order.pricelist_id.currency_id for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type != 'tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) elif line.qty != 0.0: for c in tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.qty, line.product_id, line.order_id.partner_id)['taxes']: val += c.get('amount', 0.0) res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val) return res
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val) res[order.id]['amount_total'] = res[order.id]['amount_tax'] + cur_obj.round(cr, uid, cur, val1)
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') res = {} for order in self.browse(cr, uid, ids, context=context): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } val = 0.0 cur = order.pricelist_id.currency_id for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount res[order.id]['amount_return'] += (payment.amount < 0 and payment.amount or 0) for line in order.lines: if order.price_type != 'tax_excluded': res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_inv(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty), res[order.id]['amount_tax']) elif line.qty != 0.0: for c in tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.qty, line.product_id, line.order_id.partner_id)['taxes']: val += c.get('amount', 0.0) res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val) return res
'amount_total': fields.function(_amount_total, method=True, string='Total'),
'amount_total': fields.function(_amount_all, method=True, string='Total', multi='all'),
def _get_v( self, cr, uid, ids, *a): """ Changed the Validation state of order @return: State """ res_obj = self.pool.get('res.users') company_disc = self.browse(cr, uid, ids) list_jrnl = [] r = {} if not company_disc: comp = res_obj.browse(cr, uid, uid).company_id.company_discount or 0.0 else: comp = company_disc[0] and company_disc[0].company_id and company_disc[0].company_id.company_discount or 0.0 cr.execute("SELECT discount FROM pos_order_line WHERE order_id = %s AND discount <= %s", (ids[0], comp)) res = cr.fetchone() cr.execute("SELECT discount FROM pos_order_line WHERE order_id = %s AND discount > %s", (ids[0], comp)) res2 = cr.fetchone() cr.execute("SELECT journal_id FROM account_bank_statement_line WHERE pos_statement_id = %s ", (ids[0], )) res3 = cr.fetchall() for r in res3: cr.execute("SELECT id FROM account_journal WHERE name = '%s' AND special_journal = 't'", (r[0], )) res3 = cr.fetchone() is_special = res3 and res3[0] or None if is_special: list_jrnl.append(is_special) for order in self.browse(cr, uid, ids): if order.state in ('paid', 'done', 'invoiced') and res and not res2 and not len(list_jrnl): r[order.id] = 'accepted' return r
computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['taxes'] for tax in computed_taxes: tax_amount += tax['amount'] if line.discount!=0.0: res[line.id][f] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0) else: res[line.id][f] = line.price_unit * line.qty res[line.id][f] += tax_amount
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, price, line.qty) cur = line.order_id.pricelist_id.currency_id res[line.id][f] = self.pool.get('res.currency').round(cr, uid, cur, computed_taxes['total'])
def _amount_line_all(self, cr, uid, ids, field_names, arg, context): res = dict([(i, {}) for i in ids]) account_tax_obj = self.pool.get('account.tax')
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or {}
def _adr_get(self, partner, type): res_partner = pooler.get_pool(self.cr.dbname).get('res.partner') res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address') addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type]) adr_id = addresses and addresses[type] or False return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'), 'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'),
'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder', store=True), 'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder', store=True),
def _production_date(self, cr, uid, ids, prop, unknow_none, context={}): """ Finds production planned date. @param prop: Name of field. @param unknow_none: @return: Dictionary of values. """ result = {} for prod in self.browse(cr, uid, ids, context=context): result[prod.id] = prod.date_planned[:10] return result
if not view_id: mod_obj = self.pool.get('ir.model.data') if context.get('invoice_type', False) in ('out_invoice', 'out_refund') or context.get('line_type', False) == 'customer':
mod_obj = self.pool.get('ir.model.data') if not view_id and context.get('invoice_type', False): if context.get('invoice_type', False) in ('out_invoice', 'out_refund'):
def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): if not view_id: mod_obj = self.pool.get('ir.model.data') if context.get('invoice_type', False) in ('out_invoice', 'out_refund') or context.get('line_type', False) == 'customer': result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_form') else: result = mod_obj.get_object_reference(cr, uid, 'account_voucher', 'view_vendor_payment_form') result = result and result[1] or False view_id = result res = super(account_voucher, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) doc = etree.XML(res['arch']) nodes = doc.xpath("//field[@name='partner_id']") if context.get('type', 'sale') in ('purchase', 'payment'): for node in nodes: node.set('domain', "[('supplier', '=', True)]") res['arch'] = etree.tostring(doc) return res
'datas_fname':tools.ustr( get_value( cursor, user, record_id, template.file_name, template, context ) or 'Report') + "." + format,
'datas_fname': fname,
def generate_attach_reports(self, cursor, user, template, record_id, mail, context=None): """ Generate report to be attached and attach it to the email @param cursor: Database Cursor @param user: ID of User @param template: Browse record of template @param record_id: ID of the target model for which this mail has to be generated @param mail: Browse record of email object @return: True """ reportname = 'report.' + \ self.pool.get('ir.actions.report.xml').read( cursor, user, template.report_template.id, ['report_name'], context)['report_name'] service = netsvc.LocalService(reportname) data = {} data['model'] = template.model_int_name (result, format) = service.create(cursor, user, [record_id], data, context) attachment_obj = self.pool.get('ir.attachment') new_att_vals = { 'name':mail.subject + ' (Email Attachment)', 'datas':base64.b64encode(result), 'datas_fname':tools.ustr( get_value( cursor, user, record_id, template.file_name, template, context ) or 'Report') + "." + format, 'description':mail.subject or "No Description", 'res_model':'email_template.mailbox', 'res_id':mail.id } attachment_id = attachment_obj.create(cursor, user, new_att_vals, context) if attachment_id: self.pool.get('email_template.mailbox').write( cursor, user, mail.id, { 'attachments_ids':[ [6, 0, [attachment_id]] ], 'mail_type':'multipart/mixed' }, context) return True
if not tools._email_send(msg, openobject_id=res_id) and email_error:
if not tools.misc._email_send(msg, openobject_id=res_id) and email_error:
def email_forward(self, cr, uid, model, res_ids, msg, email_error=False, context=None): """Sends an email to all people following the thread @param res_id: Id of the record of OpenObject model created from the email message @param msg: email.message.Message to forward @param email_error: Default Email address in case of any Problem """ model_pool = self.pool.get(model)
tools._email_send(msg, openobject_id=res_id)
tools.misc._email_send(msg, openobject_id=res_id)
def email_forward(self, cr, uid, model, res_ids, msg, email_error=False, context=None): """Sends an email to all people following the thread @param res_id: Id of the record of OpenObject model created from the email message @param msg: email.message.Message to forward @param email_error: Default Email address in case of any Problem """ model_pool = self.pool.get(model)
msg += "\n\nEither you wrongly customised this view, or some modules bringing those views are not compatible with your current data model"
msg += "\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model"
fields_def = self.__view_look_dom(cr, user, node, view_id, context=context)
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context=context)
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line.id, company_currency_id, next_number, context=context)
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, next_number, context=None): voucher_obj = self.pool.get('account.voucher') wf_service = netsvc.LocalService("workflow") st_line = self.pool.get('account.bank.statement.line').browse(cr, uid, st_line_id, context=context) if st_line.voucher_id: voucher_obj.write(cr, uid, [st_line.voucher_id.id], {'number': next_number}, context=context) wf_service.trg_validate(uid, 'account.voucher', st_line.voucher_id.id, 'proforma_voucher', cr) return self.pool.get('account.move.line').write(cr, uid, [x.id for x in st_line.voucher_id.move_ids], {'statement_id': st_line.statement_id.id}, context=context) return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line, company_currency_id, next_number, context=context)
unlink_ids.append(st_line.voucher_id.id)
if st_line.voucher_id: unlink_ids.append(st_line.voucher_id.id)
def unlink(self, cr, uid, ids, context=None): statement_line = self.browse(cr, uid, ids, context) unlink_ids = [] for st_line in statement_line: unlink_ids.append(st_line.voucher_id.id) self.pool.get('account.voucher').unlink(cr, uid, unlink_ids, context=context) return super(account_bank_statement_line, self).unlink(cr, uid, ids, context=context)
'account_id': acc,
'account_id': acc.id,
def action_invoice_create(self, cr, uid, ids): res = False invoice_obj = self.pool.get('account.invoice') for exp in self.browse(cr, uid, ids): lines = [] for l in exp.line_ids: tax_id = [] if l.product_id: acc = l.product_id.product_tmpl_id.property_account_expense.id if not acc: acc = l.product_id.categ_id.property_account_expense_categ.id tax_id = [x.id for x in l.product_id.supplier_taxes_id] else: acc = self.pool.get('ir.property').get(cr, uid, 'property_account_expense_categ', 'product.category') if not acc: raise osv.except_osv(_('Error !'), _('Please configure Default Expanse account for Product purchase, `property_account_expense_categ`'))
base_calendar.base_calendar_id2real_id(id)
base_calendar_id2real_id(id)
def onchange_edit_all(self, cr, uid, ids, rrule_type,edit_all, context=None): if not context: context = {} data_obj = self.pool.get('ir.model.data') value = {} if edit_all and rrule_type: for id in ids: base_calendar.base_calendar_id2real_id(id) return value
def __getitem__(self, y): return self.dict.__getitem__(y)
def __ge__(self, y): return self.dict.__ge__(y)
'amount': fields.function(_compute_total, method=True, type='float', digits=(14,2), string='Total', store=True), 'tax_amount':fields.float('Tax Amount', digits=(14,2), readonly=True, states={'draft':[('readonly',False)]}),
'amount': fields.float('Total', digits=(16, 2), readonly=True, states={'draft':[('readonly',False)]}), 'tax_amount':fields.float('Tax Amount', digits=(14,4), readonly=True, states={'draft':[('readonly',False)]}),
def _compute_total(self, cr, uid, ids, name, args, context=None): position_pool = self.pool.get('account.fiscal.position') voucher_pool = self.pool.get('account.voucher') voucher_line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') tax_pool = self.pool.get('account.tax') res = {} for voucher in self.browse(cr, uid, ids): total = 0.0 for line in voucher.payment_ids: total += line.amount
'name': lambda *a: '/',
'name': lambda *a: '',
def _compute_total(self, cr, uid, ids, name, args, context=None): position_pool = self.pool.get('account.fiscal.position') voucher_pool = self.pool.get('account.voucher') voucher_line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') tax_pool = self.pool.get('account.tax') res = {} for voucher in self.browse(cr, uid, ids): total = 0.0 for line in voucher.payment_ids: total += line.amount
def onchange_tax_id(self, cr, uid, ids, amount, tax_id, context={}):
def onchange_price(self, cr, uid, ids, payment_ids, tax_amount, tax_id, context={}):
def onchange_tax_id(self, cr, uid, ids, amount, tax_id, context={}): res = { 'tax_amount':False } tax_pool = self.pool.get('account.tax') if tax_id: tax = tax_pool.browse(cr, uid, tax_id) if tax.type == 'percent': res.update({ 'tax_amount':amount * tax.amount }) if tax.type == 'fixed': res.update({ 'tax_amount':amount + tax.amount }) return { 'value':res }
'tax_amount':False
'tax_amount':False, 'amount':False
def onchange_tax_id(self, cr, uid, ids, amount, tax_id, context={}): res = { 'tax_amount':False } tax_pool = self.pool.get('account.tax') if tax_id: tax = tax_pool.browse(cr, uid, tax_id) if tax.type == 'percent': res.update({ 'tax_amount':amount * tax.amount }) if tax.type == 'fixed': res.update({ 'tax_amount':amount + tax.amount }) return { 'value':res }
res.update({ 'tax_amount':amount * tax.amount })
tax_amount = total * tax_amount and tax_amount or tax.amount
def onchange_tax_id(self, cr, uid, ids, amount, tax_id, context={}): res = { 'tax_amount':False } tax_pool = self.pool.get('account.tax') if tax_id: tax = tax_pool.browse(cr, uid, tax_id) if tax.type == 'percent': res.update({ 'tax_amount':amount * tax.amount }) if tax.type == 'fixed': res.update({ 'tax_amount':amount + tax.amount }) return { 'value':res }
res.update({ 'tax_amount':amount + tax.amount })
tax_amount = tax_amount and tax_amount or tax.amount res.update({ 'amount':total + tax_amount, 'tax_amount':tax_amount })
def onchange_tax_id(self, cr, uid, ids, amount, tax_id, context={}): res = { 'tax_amount':False } tax_pool = self.pool.get('account.tax') if tax_id: tax = tax_pool.browse(cr, uid, tax_id) if tax.type == 'percent': res.update({ 'tax_amount':amount * tax.amount }) if tax.type == 'fixed': res.update({ 'tax_amount':amount + tax.amount }) return { 'value':res }
res.update({ 'voucher_id':res_id }) new_payment_ids += [(id1, id2, res)]
if res: res.update({ 'voucher_id':res_id }) new_payment_ids += [(id1, id2, res)]
def create(self, cr, uid, vals, context={}): """ Create a new record for a model account_voucher @param cr: A database cursor @param user: ID of the user currently logged in @param vals: provides data for new record @param context: context arguments, like lang, time zone @return: Returns an id of the new record """
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}):
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, journal_id=False, context={}):
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
if ttype in ('sale', 'receipt'):
if ttype in ('sale'):
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
elif ttype in ('purchase', 'payment'):
elif ttype in ('purchase'):
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
elif ttype in ('payment', 'receipt'): journal = journal_pool.browse(cr, uid, journal_id) if ttype == 'payment': account_id = journal.default_credit_account_id.id elif ttype == 'receipt': account_id = journal.default_debit_account_id.id
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
ids = move_pool.search(cr, uid, [('reconcile_id','=', False), ('state','=','posted'), ('partner_id','=',partner_id)], context=context) for move in move_pool.browse(cr, uid, ids): rs = { 'ref':move.ref or '/', 'move_id':move.id,
ids = move_line_pool.search(cr, uid, [('reconcile_id','=', False), ('partner_id','=',partner_id)], context=context) for line in move_line_pool.browse(cr, uid, ids): rs = move_line_pool.default_get(cr, uid, move_line_pool._columns.keys(), context=context) rs.update({ 'ref':line.ref or '/', 'move_id':line.move_id.id, 'move_line_id':line.id,
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
}
})
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
'account_id':move.partner_id.property_account_payable.id,
'account_id':line.move_id.partner_id.property_account_payable.id,
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
'amount':move.amount
'amount':line.credit
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
'account_id':move.partner_id.property_account_receivable.id,
'account_id':line.move_id.partner_id.property_account_receivable.id,
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
'amount':move.amount
'amount':line.debit
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
line_id = line_pool.create(cr, uid, rs)
line_id = line_pool.create(cr, uid, rs, context=context)
def onchange_partner_id(self, cr, uid, ids, partner_id, ttype, context={}): """ Returns a dict that contains new values and context @param cr: A database cursor @param user: ID of the user currently logged in @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 """ move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') partner_pool = self.pool.get('res.partner') res = [] context.update({ 'type':ttype, 'partner_id':partner_id, 'voucher':True, }) default = { 'value':{}, 'context':context, } if not partner_id or not ttype: if ids: line_ids = line_pool.search(cr, uid, [('voucher_id','=',ids[0])]) if line_ids: line_pool.unlink(cr, uid, line_ids) return default
'account_id':False,
'account_id':inv.account_id.id,
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
'account_id':inv.account_id.id,
def action_move_line_create(self, cr, uid, ids, *args): journal_pool = self.pool.get('account.journal') sequence_pool = self.pool.get('ir.sequence') move_pool = self.pool.get('account.move') move_line_pool = self.pool.get('account.move.line') analytic_pool = self.pool.get('account.analytic.line') currency_pool = self.pool.get('res.currency') invoice_pool = self.pool.get('account.invoice') for inv in self.browse(cr, uid, ids): if inv.move_id: continue
'name':fields.related('voucher_id', 'name', size=256, type='char', string='Description'),
'name':fields.char('Description', size=256, required=True),
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Returns views and fields for current model where view will depend on {view_type}. @param cr: A database cursor @param user: ID of the user currently logged in @param view_id: list of fields, which required to read signatures @param view_type: defines a view type. it can be one of (form, tree, graph, calender, gantt, search, mdx) @param context: context arguments, like lang, time zone @param toolbar: contains a list of reports, wizards, and links related to current model @return: Returns a dict that contains definition for fields, views, and toolbars """ data_pool = self.pool.get('ir.model.data') journal_pool = self.pool.get('account.journal') voucher_type = { 'sale':'view_sale_receipt_form', 'purchase':'view_purchase_receipt_form', 'payment':'view_vendor_payment_form', 'receipt':'view_vendor_receipt_form' }
pick_name = picking.name
pick_name = picking.name or ''
def create_chained_picking(self, cr, uid, moves, context=None): new_moves = [] res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') if context is None: context = {} for picking, todo in self._chain_compute(cr, uid, moves, context=context).items(): ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0]) pick_name = picking.name if ptype == 'delivery': pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery')
pickid = picking_obj.create(cr, uid, { 'name': pick_name, 'origin': str(picking.origin or ''), 'type': ptype, 'note': picking.note, 'move_type': picking.move_type, 'auto_picking': todo[0][1][1] == 'auto', 'stock_journal_id': todo[0][1][3], 'company_id': todo[0][1][4] or res_obj._company_default_get(cr, uid, 'stock.company', context), 'address_id': picking.address_id.id, 'invoice_state': 'none', 'date': picking.date, 'sale_id':' sale_id' in picking._columns.keys() and picking.sale_id.id or False })
check_picking_ids = picking_obj.search(cr, uid, [('name','=',picking.name),('origin','=',str(picking.origin or '')),('type','=',ptype),('move_type','=',picking.move_type)]) if check_picking_ids: pickid = check_picking_ids[0] else: if picking: pickid = picking_obj.create(cr, uid, { 'name': pick_name, 'origin': str(picking.origin or ''), 'type': ptype, 'note': picking.note, 'move_type': picking.move_type, 'auto_picking': todo[0][1][1] == 'auto', 'stock_journal_id': todo[0][1][3], 'company_id': todo[0][1][4] or res_obj._company_default_get(cr, uid, 'stock.company', context=context), 'address_id': picking.address_id.id, 'invoice_state': 'none', 'date': picking.date, 'sale_id':' sale_id' in picking._columns.keys() and picking.sale_id.id or False }) else: pickid = False
def create_chained_picking(self, cr, uid, moves, context=None): new_moves = [] res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') if context is None: context = {} for picking, todo in self._chain_compute(cr, uid, moves, context=context).items(): ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0]) pick_name = picking.name if ptype == 'delivery': pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery')
'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context) ,
'company_id': company_id or res_obj._company_default_get(cr, uid, 'stock.company', context=context) ,
def create_chained_picking(self, cr, uid, moves, context=None): new_moves = [] res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') if context is None: context = {} for picking, todo in self._chain_compute(cr, uid, moves, context=context).items(): ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0]) pick_name = picking.name if ptype == 'delivery': pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery')
wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
if pickid: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
def create_chained_picking(self, cr, uid, moves, context=None): new_moves = [] res_obj = self.pool.get('res.company') picking_obj = self.pool.get('stock.picking') move_obj = self.pool.get('stock.move') if context is None: context = {} for picking, todo in self._chain_compute(cr, uid, moves, context=context).items(): ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0]) pick_name = picking.name if ptype == 'delivery': pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery')
last_track = [line.tracking_id.id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.tracking_id] if not last_track: last_track = tracking_obj.create(cr, uid, {}, context=context) else: last_track.sort() last_track = last_track[-1] self.write(cr, uid, ids, {'tracking_id': last_track})
picking = self.browse(cr, uid, ids)[0].picking_id if picking: last_track = [line.tracking_id.id for line in picking.move_lines if line.tracking_id] if not last_track: last_track = tracking_obj.create(cr, uid, {}, context=context) else: last_track.sort() last_track = last_track[-1] self.write(cr, uid, ids, {'tracking_id': last_track})
def setlast_tracking(self, cr, uid, ids, context=None): tracking_obj = self.pool.get('stock.tracking') tracking = context.get('tracking', False) last_track = [line.tracking_id.id for line in self.browse(cr, uid, ids)[0].picking_id.move_lines if line.tracking_id] if not last_track: last_track = tracking_obj.create(cr, uid, {}, context=context) else: last_track.sort() last_track = last_track[-1] self.write(cr, uid, ids, {'tracking_id': last_track}) return True
coeff_def2uom, rounding = self._from_default_uom_factor( cr, uid, val, product_uom, {})
coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {})
def product_amt_change(self, cr, uid, ids, product_amt = 0.0, product_uom=False): ret={} if product_amt: coeff_def2uom = 1 val1 = self.browse(cr, uid, ids) val = val1[0] if (product_uom != val.product_id.uom_id.id): coeff_def2uom, rounding = self._from_default_uom_factor( cr, uid, val, product_uom, {}) ret['product_qty'] = rounding(coeff_def2uom * product_amt/(val.product_id.product_tmpl_id.list_price), round_value) res = {'value': ret} return res
order = self.pool.get('pos.order').browse(cr, uid, active_id) if order.amount_total == order.amount_paid: res['arch'] = """ <form string="Make Payment" colspan="4"> <group col="2" colspan="2"> <label string="Do you want to print the Receipt?" colspan="4"/> <separator colspan="4"/> <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/> <button name="print_report" string="Print Receipt" type="object" icon="gtk-print"/> </group> </form> """ return res
try: order = self.pool.get('pos.order').browse(cr, uid, active_id) if order.amount_total == order.amount_paid: res['arch'] = """ <form string="Make Payment" colspan="4"> <group col="2" colspan="2"> <label string="Do you want to print the Receipt?" colspan="4"/> <separator colspan="4"/> <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/> <button name="print_report" string="Print Receipt" type="object" icon="gtk-print"/> </group> </form> """ except: return result return result
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Changes the view dynamically @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return: New arch of view. """ result = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) active_model = context.get('active_model') if not active_model and active_model != 'pos.order': return result active_id = context.get('active_id', False) if active_id: order = self.pool.get('pos.order').browse(cr, uid, active_id) if order.amount_total == order.amount_paid: res['arch'] = """ <form string="Make Payment" colspan="4"> <group col="2" colspan="2"> <label string="Do you want to print the Receipt?" colspan="4"/> <separator colspan="4"/> <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/> <button name="print_report" string="Print Receipt" type="object" icon="gtk-print"/> </group> </form> """ return res
self.baseuri = "http://%s:%d/"% (self.server.server_name, self.server.server_port)
addr, port = self.server.server_name, self.server.server_port try: addr, port = self.request.getsockname() except Exception, e: self.log_error("Cannot calculate own address:" , e) self.baseuri = "http://%s:%d/"% (addr, port)
def setup(self): self.davpath = '/'+config.get_misc('webdav','vdir','webdav') self.baseuri = "http://%s:%d/"% (self.server.server_name, self.server.server_port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose)
'origin': fields.related('picking_id','origin',type='char', size=64, relation="stock.picking", string="Origin"),
'origin': fields.related('picking_id','origin',type='char', size=64, relation="stock.picking", string="Origin",store=True),
def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True
'partner_id': fields.related('partner_address_id', 'partner_id', type='many2one', relation='res.partner', string='Partner'),
'partner_id': fields.related('partner_address_id', 'partner_id', type='many2one', relation='res.partner', string='Partner', help="Partner related to contact"),
def _lang_get(self, cr, uid, context={}): obj = self.pool.get('res.lang') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['code', 'name'], context) res = [((r['code']).replace('_', '-'), r['name']) for r in res] return res
res_id = False model = None
res_id = context.get('active_id') model = context.get('active_model')
def on_change_history(self, cr, uid, ids, history, context=None): """Gives message body according to type of history selected * info: Forward the case information * whole: Send the whole history * latest: Send the latest histoy @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 history IDs @param context: A standard dictionary for contextual values """ #TODO: ids and context are not comming res = False msg_val = '' res_id = False # Comes from context model = None # Comes from context model_pool = self.pool.get(model) if not res_id or not model: return res if history == 'info': msg_val = self.get_lead_details(cr, uid, res_id, context=context)
res = self.create_period(cr, uid, ids, context, 6, 'Weekly')
res = self.create_period(cr, uid, ids, context=context)
def create_period_weekly(self, cr, uid, ids, context=None): res = self.create_period(cr, uid, ids, context, 6, 'Weekly') return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
def create_period_monthly(self,cr, uid, ids, interval=1, context=None):
def create_period_monthly(self, cr, uid, ids, context=None): interval = context.get('interval',1)
def create_period_monthly(self,cr, uid, ids, interval=1, context=None): for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: de = ds + RelativeDateTime(months=interval, minutes=-1) self.pool.get('stock.period').create(cr, uid, { 'name': ds.strftime('%Y/%m'), 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + RelativeDateTime(months=interval) return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
def create_period(self, cr, uid, ids, interval=0, name='Daily', context=None):
def create_period(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily')
def create_period(self, cr, uid, ids, interval=0, name='Daily', context=None): for p in self.browse(cr, uid, ids, context=context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d') < p.date_stop: de = ds + RelativeDateTime(days=interval, minutes =-1) if name =='Daily': new_name=de.strftime('%Y-%m-%d') if name =="Weekly": new_name = de.strftime('%Y, week %W') self.pool.get('stock.period').create(cr, uid, { 'name': new_name, 'date_start': ds.strftime('%Y-%m-%d'), 'date_stop': de.strftime('%Y-%m-%d %H:%M:%S'), }) ds = ds + RelativeDateTime(days=interval) + 1 return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
if address_id:
if address_id['default']:
def action_apply(self, cr, uid, ids, context=None): """ This converts Phonecall to Opportunity and opens Phonecall view @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 Phonecall to Opportunity IDs @param context: A standard dictionary for contextual values
return [(str(r['id']),r['name']) for r in res] cr.execute("""SELECT to_char(id, '99999'),name FROM project_project where manager=%s OR id IN (SELECT project_id from project_user_rel where uid=%s)""" % (uid, uid)) return cr.fetchall()
else: cr.execute("""SELECT project.id,project.name FROM project_project project LEFT JOIN account_analytic_account account ON account.id = project.category_id WHERE (account.user_id = %s)""", uid) res = cr.fetchall() res = [(str(r['id']),r['name']) for r in res] return res
def _project_get(self, cr, uid, context={}): if uid==1: ids = self.pool.get('project.project').search(cr, uid, []) res = self.pool.get('project.project').read(cr, uid, ids, ['id','name'], context) return [(str(r['id']),r['name']) for r in res] cr.execute("""SELECT to_char(id, '99999'),name FROM project_project where manager=%s OR id IN (SELECT project_id from project_user_rel where uid=%s)""" % (uid, uid)) return cr.fetchall()
cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id=%s AND (date "
if line.analytic_account_id.id: cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id=%s AND (date "
def _prac_amt(self, cr, uid, ids, context={}): res = {} for line in self.browse(cr, uid, ids): acc_ids = [x.id for x in line.general_budget_id.account_ids] if not acc_ids: raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name)) date_to = line.date_to date_from = line.date_from if context.has_key('wizard_date_from'): date_from = context['wizard_date_from'] if context.has_key('wizard_date_to'): date_to = context['wizard_date_to'] cr.execute("SELECT SUM(amount) FROM account_analytic_line WHERE account_id=%s AND (date " "between to_date(%s,'yyyy-mm-dd') AND to_date(%s,'yyyy-mm-dd')) AND " "general_account_id=ANY(%s)", (line.analytic_account_id.id, date_from, date_to,acc_ids,)) result = cr.fetchone()[0] if result is None: result = 0.00 res[line.id] = result return res
sub = (email.Subject).replace(' ','')
sub = msg.get('subject','NO-SUBJECT').replace(' ','')
def history_message(self, cr, uid, vals): dictcreate = dict(vals) ref_ids = str(dictcreate.get('ref_ids')).split(';') msg = dictcreate.get('message') msg = self.pool.get('email.server.tools').parse_message(msg) server_tools_pool = self.pool.get('email.server.tools') message_id = msg.get('message-id', False) msg_pool = self.pool.get('mailgate.message') msg_ids = [] res = {} res_ids = [] obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] for ref_id in ref_ids: msg_new = dictcreate.get('message') ref = ref_id.split(',') model = ref[0] res_id = int(ref[1]) if message_id: msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)]) if msg_ids and len(msg_ids): continue if model not in obj_list: res={} obj_attch = self.pool.get('ir.attachment') ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|', '\t', '\n',':','~'] sub = (email.Subject).replace(' ','') if sub.strip() == '': sub = 'NO SBUJECT' fn = sub for c in ls: fn = fn.replace(c,'') if len(fn) > 64: l = 64 - len(fn) f = fn.split('-') fn = '-'.join(f[1:]) if len(fn) > 64: l = 64 - len(fn) f = fn.split('.') fn = f[0][0:l] + '.' + f[-1] fn = fn[:-4]+'.txt' res['res_model'] = model res['name'] = msg.get('subject','NO-SUBJECT') res['datas_fname'] = fn res['datas'] = base64.b64encode(msg.get('body')) res['res_id'] = res_id obj_attch.create(cr, uid, res) server_tools_pool.history_message(cr, uid, model, res_id, msg_new) res_ids.append(res_id) return len(res_ids)
new_ids = ids
new_ids = 'active_ids' in data['form']['context'] and data['form']['context']['active_ids'] or []
def set_context(self, objects, data, ids, report_type = None): ## self.borne_date = self.get_min_date(data['form']) ## new_ids = [] if (data['model'] == 'account.account'): new_ids = ids else: new_ids.append(data['form']['Account_list'])
cr.sql_log=1
def __init__(self, cr, uid, name, context): super(general_ledger, self).__init__(cr, uid, name, context=context) cr.sql_log=1 self.date_borne = {} self.query = "" self.child_ids = "" self.tot_currency = 0.0 self.period_sql = "" self.sold_accounts = {} self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit_account': self._sum_debit_account, 'sum_credit_account': self._sum_credit_account, 'sum_solde_account': self._sum_solde_account, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'sum_solde': self._sum_solde, 'get_children_accounts': self.get_children_accounts, 'sum_currency_amount_account': self._sum_currency_amount_account }) self.context = context
other_invitation_ids = self.search(cr, uid, [('ref', '=', res_obj._name + ',' + str(res_obj.id))])a
other_invitation_ids = self.search(cr, uid, [('ref', '=', res_obj._name + ',' + str(res_obj.id))])
def _send_mail(self, cr, uid, ids, mail_to, email_from=tools.config.get('email_from', False), context=None): """ Send mail for event invitation to event attendees. @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of attendee’s IDs. @param email_from: Email address for user sending the mail @param context: A standard dictionary for contextual values @return: True """ if not context: context = {}
return {'value': {'vtimezone': None}} value = {'vtimezone': None}
return {'value': {'vtimezone': False}} value = {'vtimezone': False}
def onchange_user_id(self, cr, uid, ids, user_id, *args, **argv): if not user_id: return {'value': {'vtimezone': None}} value = {'vtimezone': None} cr.execute('select context_tz from res_users where id=%s' % (user_id)) timezone = cr.fetchone()[0] if timezone: value.update({'vtimezone': timezone.lower()}) return {'value': value}
cr.execute('select id from %s where recurrent_uid=%s' % (self._table, event_id))
cr.execute("select id from %s where recurrent_uid=%%s" % (self._table), (event_id,))
def unlink_events(self, cr, uid, ids, context=None): """ This function deletes event which are linked with the event with recurrent_uid (Removes the events which refers to the same UID value) """ if not context: context = {} for event_id in ids: cr.execute('select id from %s where recurrent_uid=%s' % (self._table, event_id)) r_ids = map(lambda x: x[0], cr.fetchall()) self.unlink(cr, uid, r_ids, context=context) return True
cr.execute(qry, val)
cr.execute(qry % val)
def _set_rrulestring(self, cr, uid, id, name, value, arg, context=None): """ Sets values of fields that defines event recurrence from the value of rrule string @param self: The object pointer @param cr: the current row, from the database cursor, @param id: List of calendar event's ids. @param context: A standard dictionary for contextual values @return: dictionary of rrule value. """ if not context: context = {} cr.execute("UPDATE %s set freq='None',interval=0,count=0,end_date=Null,\ mo=False,tu=False,we=False,th=False,fr=False,sa=False,su=False,\ day=0,select1='date',month_list=Null ,byday=Null where id=%%s" % (self._table), (id,))
resource = reduce(operator.or_, resources)
try: resource = reduce(operator.or_, resources) except: raise osv.except_osv(_('Error'), _('Should have Resources Allocation or Project Members!'))
def Project(): title = "Project" start = datetime.strftime(datetime.strptime(start_date, "%Y-%m-%d"), "%Y-%m-%d %H:%M") resource = reduce(operator.or_, resources) minimum_time_unit = 1 if calendar_id: # If project has working calendar working_days = resource_pool.compute_working_calendar(cr, uid, calendar_id, context=context) vacation = tuple(resource_pool.compute_vacation(cr, uid, calendar_id, context=context)) # Dynamic creation of tasks task_number = 0 for openobect_task in self.browse(cr, uid, ids, context=context): hours = str(openobect_task.planned_hours )+ 'H' if openobect_task.priority in priority_dict.keys(): priorty = priority_dict[openobect_task.priority] real_resource = False if openobect_task.user_id: for task_resource in resources: if task_resource.__name__ == task_resource: real_resource = task_resource break task = create_tasks(task_number, hours, priorty, real_resource) task_number += 1
categ_ids = categ_obj.search(cr, uid, [('name','ilike','Part%')])
categ_ids = categ_obj.search(cr, uid, [('name','ilike','other%')])
def make_opportunity(self, cr, uid, ids, context): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
leaves = wkcal.compute_leaves(cr, uid, calendar_id , resource_id[0], resource.get('calendar_id')[0])
if resource.get('calendar_id', False): leaves = wkcal.compute_leaves(cr, uid, calendar_id , resource_id[0], resource['calendar_id'] and resource['calendar_id'][0] or False)
def _compute_date(self, cr, uid, data, context): """ Schedule the tasks according to resource available and priority. """ pool = pooler.get_pool(cr.dbname) project_obj = pool.get('project.project') task_pool = pool.get('project.task') resource_obj = pool.get('resource.resource') user_obj = pool.get('res.users') project_id = data['form']['project_id'] project = project_obj.browse(cr, uid, project_id, context=context) task_ids = task_pool.search(cr, uid, [('project_id', '=', project_id), ('state', 'in', ['draft', 'open', 'pending']) ]) if task_ids: task_ids.sort() tasks = task_pool.browse(cr, uid, task_ids, context=context) calendar_id = project.resource_calendar_id and project.resource_calendar_id.id or False start_date = project.date_start if not project.date_start: start_date = datetime.datetime.now().strftime("%Y-%m-%d") date_start = datetime.datetime.strftime(datetime.datetime.strptime(start_date, "%Y-%m-%d"), "%Y-%m-%d %H:%M") # Create Resource Class objects which are the Project Members resources = [] for user in project.members: leaves = [] time_efficiency = 1.0 resource_id = resource_obj.search(cr, uid, [('user_id', '=', user.id)], context=context) if resource_id:
elif data['form']['result_selection'] == 'customer': self.ACCOUNT_TYPE = ['payable']
def set_context(self, objects, data, ids, report_type = None): PARTNER_REQUEST = '' if (data['model'] == 'res.partner'): ## Si on imprime depuis les partenaires if ids: #PARTNER_REQUEST = "AND line.partner_id IN (" + ','.join(map(str, ids)) + ")" PARTNER_REQUEST = "AND line.partner_id =ANY(%s)" %ids # Transformation des date # #
mname = prefix + "_" + prop
mname = prefix + "_" + prop.replace('-','_')
def get_dav_eprop(self, cr, ns, prop): if not self.DAV_M_NS: return None if self.DAV_M_NS.has_key(ns): prefix = self.DAV_M_NS[ns] else: logger.debug('No namespace: %s ("%s")',ns, prop) return None
company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id
company_id = self.browse(cr, uid, ids, context)[0].company_id
def generate_configurable_chart(self, cr, uid, ids, context=None): obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') mod_obj = self.pool.get('ir.model.data')
company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id
company_id = record.company_id
def execute(self, cr, uid, ids, context=None): if context is None: context = {} fy_obj = self.pool.get('account.fiscalyear') mod_obj = self.pool.get('ir.model.data') obj_acc = self.pool.get('account.account') obj_tax_code = self.pool.get('account.tax.code') obj_temp_tax_code = self.pool.get('account.tax.code.template') super(account_installer, self).execute(cr, uid, ids, context=context) record = self.browse(cr, uid, ids, context=context)[0] company_id = self.pool.get('res.users').browse(cr, uid, [uid], context)[0].company_id for res in self.read(cr, uid, ids): if record.charts == 'configurable': fp = tools.file_open(opj('account','configurable_account_chart.xml')) tools.convert_xml_import(cr, 'account', fp, {}, 'init',True, None) fp.close() self.generate_configurable_chart(cr, uid, ids, context=context) obj_tax = self.pool.get('account.tax') obj_product = self.pool.get('product.product') ir_values = self.pool.get('ir.values') s_tax = (res.get('sale_tax',0.0))/100 p_tax = (res.get('purchase_tax',0.0))/100 tax_val = {} default_tax = []
def print_report(self, cr, uid, ids, context=None):
def print_report(self, cr, uid, ids, context={}):
def print_report(self, cr, uid, ids, context=None):
@summary: To get the date and print the report @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : retrun report """ datas = {'ids' : context.get('active_ids',[])} res = self.read(cr, uid, ids, ['date_start','date_end'])
To get the date and print the report @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : retrun report """ datas = {'ids' : context.get('active_ids', [])} res = self.read(cr, uid, ids, ['date_start','date_end'], context)
def print_report(self, cr, uid, ids, context=None):
def _get_type(self, cr, uid, ids, context=None): if context is None: context = {}
def _get_type(self, cr, uid, context=None): if context is None: context = {}
def _get_type(self, cr, uid, ids, context=None): if context is None: context = {} return context.get('type', False)
act_ids = [ act_id.id for act_id in campaign.activity_ids] act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid, [('id', 'in', act_ids), ('start', '=', True)])
actvity_ids = [ act_id.id for act_id in campaign.activity_ids] act_obj = self.pool.get('marketing.campaign.activity') act_ids = act_obj.search(cr, uid, [('id', 'in', actvity_ids), ('start', '=', True)])
def state_running_set(self, cr, uid, ids, *args): campaign = self.browse(cr, uid, ids[0]) if not campaign.activity_ids : raise osv.except_osv("Error", "There is no activitity in the campaign") act_ids = [ act_id.id for act_id in campaign.activity_ids] act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid, [('id', 'in', act_ids), ('start', '=', True)]) if not act_ids : raise osv.except_osv("Error", "There is no starting activitity in the campaign") self.write(cr, uid, ids, {'state': 'running'}) return True
'server_action' : self.process_wi_action,
'action' : self.process_wi_action,
def __init__(self, *args): self._actions = {'paper' : self.process_wi_report, 'email' : self.process_wi_email, 'server_action' : self.process_wi_action, } return super(marketing_campaign_activity, self).__init__(*args)
server_obj.run(cr, uid, [activity.server_action_id.id], context) return True
context['active_id'] = workitem.res_id return server_obj.run(cr, uid, [activity.server_action_id.id], context)
def process_wi_action(self, cr, uid, activity, workitem, context={}): context = {} server_obj = self.pool.get('ir.actions.server') server_obj.run(cr, uid, [activity.server_action_id.id], context) return True