rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
'account_analytic_id': ol.account_analytic_id.id,
'account_analytic_id': ol.account_analytic_id.id or False,
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_...
return ids
return ids and ids[0] or False
def find(self, cr, uid, dt=None, context={}): if not dt: dt = time.strftime('%Y-%m-%d')
cr.execute('SELECT db_datas FROM ir_attachment WHERE id = %s', ira_browse.id)
cr = ira_browse._cr cr.execute('SELECT db_datas FROM ir_attachment WHERE id = %s',(ira_browse.id,))
def __init__(self, parent, ira_browse, mode): nodes.node_descriptor.__init__(self, parent) if mode.endswith('b'): mode = mode[:-1] if mode in ('r', 'r+'): cr.execute('SELECT db_datas FROM ir_attachment WHERE id = %s', ira_browse.id) data = cr.fetchone()[0] StringIO.__init__(self, data) elif mode in ('w', 'w+'): String...
out = self.getvalue() cr.execute("UPDATE ir_attachment SET db_datas = decode(%s,'escape'), file_size=%s WHERE id = %s", (out, len(out), par.file_id))
data = self.getvalue() out = psycopg2.Binary(data) cr.execute("UPDATE ir_attachment SET db_datas = %s, file_size=%s WHERE id = %s", (out, len(data), par.file_id))
def close(self): # we now open a *separate* cursor, to update the data. # FIXME: this may be improved, for concurrency handling par = self._get_parent() uid = par.context.uid cr = pooler.get_db(par.context.dbname).cursor() try: if self.mode in ('w', 'w+', 'r+'): out = self.getvalue() cr.execute("UPDATE ir_attachment SE...
out = self.getvalue()
data = self.getvalue() out = psycopg2.Binary(data)
def close(self): # we now open a *separate* cursor, to update the data. # FIXME: this may be improved, for concurrency handling par = self._get_parent() uid = par.context.uid cr = pooler.get_db(par.context.dbname).cursor() try: if self.mode in ('w', 'w+', 'r+'): out = self.getvalue() cr.execute("UPDATE ir_attachment SE...
"SET db_datas = COALESCE(db_datas,'') || decode(%s, 'escape'), " \
"SET db_datas = COALESCE(db_datas,'') || %s, " \
def close(self): # we now open a *separate* cursor, to update the data. # FIXME: this may be improved, for concurrency handling par = self._get_parent() uid = par.context.uid cr = pooler.get_db(par.context.dbname).cursor() try: if self.mode in ('w', 'w+', 'r+'): out = self.getvalue() cr.execute("UPDATE ir_attachment SE...
(out, len(out), par.file_id))
(out, len(data), par.file_id))
def close(self): # we now open a *separate* cursor, to update the data. # FIXME: this may be improved, for concurrency handling par = self._get_parent() uid = par.context.uid cr = pooler.get_db(par.context.dbname).cursor() try: if self.mode in ('w', 'w+', 'r+'): out = self.getvalue() cr.execute("UPDATE ir_attachment SE...
(data, file_node.file_id))
(out, file_node.file_id))
def set_data(self, cr, uid, id, file_node, data, context=None, fil_obj=None): """ store the data. This function MUST be used from an ir.attachment. It wouldn't make sense to store things persistently for other types (dynamic). """ if not context: context = {} boo = self.browse(cr, uid, id, context) if fil_obj: ira = fi...
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
'priority': crm.AVAILABLE_PRIORITIES[2][0], 'type': 'opportunity',
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
'name': fields.char('Marital Status', size=32, required=True),
'name': fields.char('Marital Status', size=32, required=True, translate=True),
def _check_recursion(self, cr, uid, ids, context=None): level = 100 while len(ids): cr.execute('select distinct parent_id from hr_employee_category where id IN %s', (tuple(ids), )) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True
'fiscalyear_id': inv.period_id.fiscalyear_id.id
'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id
def action_number(self, cr, uid, ids, *args): for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } ...
if inv.journal_id.invoice_sequence_id: sequence_id = inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid,
if obj_inv.journal_id.invoice_sequence_id: sequence_id = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid,
def action_number(self, cr, uid, ids, *args): for obj_inv in self.browse(cr, uid, ids): id = obj_inv.id invtype = obj_inv.type number = obj_inv.number move_id = obj_inv.move_id and obj_inv.move_id.id or False reference = obj_inv.reference if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } ...
res = [tax.name for tax in pooler.get_pool(cr.dbname).get('account.tax').browse(self.cr, self.uid, tax_ids)]
res = [tax.name for tax in pooler.get_pool(self.cr.dbname).get('account.tax').browse(self.cr, self.uid, tax_ids)]
def _get_line_tax(self, line_obj): self.cr.execute("SELECT tax_id FROM purchase_order_taxe WHERE order_line_id=%s", (line_obj.id)) res = self.cr.fetchall() or None if not res: return "" if isinstance(res, list): tax_ids = [t[0] for t in res] else: tax_ids = res[0] res = [tax.name for tax in pooler.get_pool(cr.dbname).g...
tax_obj = pooler.get_pool(cr.dbname).get('account.tax')
tax_obj = pooler.get_pool(self.cr.dbname).get('account.tax')
def _get_tax(self, order_obj): self.cr.execute("SELECT DISTINCT tax_id FROM purchase_order_taxe, purchase_order_line, purchase_order \ WHERE (purchase_order_line.order_id=purchase_order.id) AND (purchase_order.id=%s)", (order_obj.id)) res = self.cr.fetchall() or None if not res: return [] if isinstance(res, list): tax_...
for line in pooler.get_pool(cr.dbname).get('purchase.order.line').browse(self.cr, self.uid, line_ids):
for line in pooler.get_pool(self.cr.dbname).get('purchase.order.line').browse(self.cr, self.uid, line_ids):
def _get_tax(self, order_obj): self.cr.execute("SELECT DISTINCT tax_id FROM purchase_order_taxe, purchase_order_line, purchase_order \ WHERE (purchase_order_line.order_id=purchase_order.id) AND (purchase_order.id=%s)", (order_obj.id)) res = self.cr.fetchall() or None if not res: return [] if isinstance(res, list): tax_...
'picking_ids': fields.one2many('stock.picking', 'sale_id', 'Related Picking', readonly=True, help="This is the list of picking list that have been generated for this invoice"),
'picking_ids': fields.one2many('stock.picking', 'sale_id', 'Related Picking', readonly=True, help="This is a list of picking that has been generated for this sale order"),
def _get_order(self, cr, uid, ids, context=None): if context is None: context = {} result = {} for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): result[line.order_id.id] = True return result.keys()
new_picking = pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name,
new_picking = pick_obj.copy(cr, uid, pick.id, {'name':'%s-return' % pick.name,
def create_returns(self, cr, uid, ids, context): """ Creates return picking. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: List of ids selected @param context: A standard dictionary @return: A dictionary which of fields with values. """ record_i...
_name = 'report.account.tax.code.entries'
def _record_to_report_line(record): return {'date': record.date, 'ref': record.ref, 'acode': record.account_id.code, 'name': record.name, 'debit': record.debit, 'credit': record.credit, 'pname': record.partner_id and record.partner_id.name or '', 'country': _get_country(record) }
return {'nodestroy':True,}
return {}
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_obj = self.pool.get('payment.line') if context is None: context = {} data = self.read(cr, uid, ids, [])[0] line_ids = data['entries'] if not line_ids: return {}
fields[field.field] = [None, journal.id]
fields[field.field] = [journal.id]
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) if view_type != 'tree': return result
pdt = datetime.datetime.strftime(date_dt,"%Y-%m-%d %H:%M") class user(Resource): pass
dt = datetime.datetime.strftime(date_dt,"%Y-%m-%d %H:%M")
def _compute_date(self, cr, uid, data, context):
resource_obj = pooler.get_pool(cr.dbname).get('resource.resource').browse(cr,uid,resource_id)[0] if resource_obj.calendar_id:
if resource_id : resource_obj = pooler.get_pool(cr.dbname).get('resource.resource').browse(cr,uid,resource_id)[0] if resource_obj.calendar_id: calendar_id = resource_obj.calendar_id.id resource_leave_ids = pooler.get_pool(cr.dbname).get('resource.calendar.leaves').search(cr,uid,[('resource_id','=',resource_id)]) else: ...
def _compute_date(self, cr, uid, data, context):
b = ""
non_working = ""
def _compute_date(self, cr, uid, data, context):
week_ids = pooler.get_pool(cr.dbname).get('resource.calendar.week').search(cr,uid,[('calendar_id','=',resource_obj.calendar_id.id)])
week_ids = pooler.get_pool(cr.dbname).get('resource.calendar.week').search(cr,uid,[('calendar_id','=',calendar_id)])
def _compute_date(self, cr, uid, data, context):
b += v + ',' final_lst.append((b[:-1],time_range)) print 'Final Tlist:::',tlist
non_working += v + ',' if non_working: final_lst.append((non_working[:-1],time_range)) print 'Final list After Adding Non-Working:::',final_lst
def _compute_date(self, cr, uid, data, context):
resource_leave_ids = pooler.get_pool(cr.dbname).get('resource.calendar.leaves').search(cr,uid,[('resource_id','=',resource_id)])
def _compute_date(self, cr, uid, data, context):
ndt = pdt
new_dt = dt
def _compute_date(self, cr, uid, data, context):
ndt = data['date_end'][0:16]
new_dt = data['date_end'][0:16]
def _compute_date(self, cr, uid, data, context):
start = ndt
start = new_dt
def Project_1(): resource = user title = project.name start = ndt effort = hours
start = ndt
start = new_dt
def task1(): start = ndt effort = hours title = task_obj[i].name
paths = tools.config['addons_path'].split(",") for path in paths: full_path = os.path.join(path, 'hr/image', 'photo.png') if os.path.exists(full_path): return open(full_path,'rb') .read().encode('base64') raise Exception("photo.png could not be found")
res_path = addons.get_module_resource("hr","image/photo.png") return open(res_path,'rb').read().encode('base64')
def _get_photo(self, cr, uid, context=None): paths = tools.config['addons_path'].split(",") for path in paths: full_path = os.path.join(path, 'hr/image', 'photo.png') if os.path.exists(full_path): return open(full_path,'rb') .read().encode('base64') raise Exception("photo.png could not be found")
_order = 'default_code'
_order = 'default_code,name_template'
def _product_partner_ref(self, cr, uid, ids, name, arg, context=None): res = {} if context is None: context = {} for p in self.browse(cr, uid, ids, context=context): data = self._get_partner_code_name(cr, uid, [], p, context.get('partner_id', None), context=context) if not data['variants']: data['variants'] = p.variant...
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, ttype=False, context={}):
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, currency_id=False, ttype=False, context={}):
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, tim...
rs['amount'] = min(line.amount_unreconciled, total_debit) total_debit -= rs['amount']
amount = min(line.amount_unreconciled, total_debit) rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount) total_debit -= amount
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, tim...
rs['amount'] = min(line.amount_unreconciled, total_credit) total_credit -= rs['amount']
amount = min(line.amount_unreconciled, total_credit) rs['amount'] = currency_pool.compute(cr, uid, company_currency, currency_id, amount) total_credit -= amount
def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id=False, price=0.0, ttype=False, context={}): """price Returns a dict that contains new values and context @param partner_id: latest value from user input for field partner_id @param args: other arguments @param context: context arguments, like lang, tim...
val={} dom={}
val = {} dom = {} obj_journal = self.pool.get('account.journal')
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val={} dom={} if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if pa...
if company_id: val['journal_id']=False journal_ids=self.pool.get('account.journal').search(cr,uid,[('company_id','=',company_id)]) dom={'journal_id': [('id','in',journal_ids)]}
if company_id and type: if type in ('out_invoice', 'out_refund'): journal_type = 'sale' else: journal_type = 'purchase' journal_ids = obj_journal.search(cr, uid, [('company_id','=',company_id), ('type', '=', journal_type)]) if journal_ids: val['journal_id'] = journal_ids[0] else: raise osv.except_osv(_('Configration Er...
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val={} dom={} if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if pa...
journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]}
journal_ids = obj_journal.search(cr, uid, [])
def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val={} dom={} if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) if partner_obj.property_account_payable and partner_obj.property_account_receivable: if pa...
'addons/account/report/account_profit_horizontal.rml.rml',parser=report_pl_account_horizontal, header='internal')
'addons/account/report/account_profit_horizontal.rml',parser=report_pl_account_horizontal, header='internal')
def get_lines_another(self, group): return self.result.get(group, [])
'outlook':fields.boolean('Outlook Plug-in ', help="Allows you to select an object that you’d like to add to your email and its attachments."),
'outlook':fields.boolean('Outlook Plug-in ', help="Allows you to select an object that you would like to add to your email and its attachments."),
def default_get(self, cr, uid, fields, context=None): data = super(outlook_installer, self).default_get(cr, uid, fields, context=context) data['doc_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_outlook.html' file = open(addons.get_module_resource('outlook','plugin','openerp-outlook-addin.exe'), 'r') data[...
dim_obj = self.pool.get('olap.dimension').browse(cr, uid, int(['d_id']))
dim_obj = self.pool.get('olap.dimension').browse(cr, uid, int(context['d_id']))
def search(self, cr, uid, args, offset = 0, limit = None, order = None, context = None, count = False): if context and context.has_key('parent_schema_id'): args = [('schema_id', '=', context['parent_schema_id'])]
if wiz_id not in self.wiz_uid: super(virtual_wizard,self).exp_create(db, uid, wiz_name, datas)
def exp_execute(self, db, uid, wiz_id, datas, action='init', context=None): if wiz_id not in self.wiz_uid: # TODO: To Check why need it #if wiz_id == 1: # wiz_name ='base_setup.base_setup' #if wiz_id == 2: # wiz_name ='module.upgrade' super(virtual_wizard,self).exp_create(db, uid, wiz_name, datas) new_ids = [] if...
'pos':fields.boolean('Point of Sales'),
'point_of_sale':fields.boolean('Point of Sales'),
def _if_account(self, cr, uid, ids, context=None): chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] self.logger.notifyChannel( 'installer', netsvc.LOG_DEBUG, 'Addon "account" selected, installing chart of accounts %s'%chart) return [chart]
message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals.get('name', 'n/a')) + _(" with origin")+" '" + vals.get('origin', 'n/a') + "' "+ _("is created.")
message = type_list.get(vals.get('type', ''), _('Picking') + " '" + vals.get('name', 'n/a') + _(" with origin")+" '" + (vals.get('origin', '') or 'n/a') + "' "+ _("is created."))
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) type_list = { 'out':_('Packing List'), 'in':_('Reception'), 'internal': _('Internal picking'), 'deli...
('real_time','Real Time (automatized)'),], 'Stock Valuation', help="Decide if the system must automatically creates account moves based on stock moves", required=True),
('real_time','Real Time (automatized)'),], 'Stock Valuation', help="Decide if the system must automatically create account moves based on stock moves", required=True),
def _product_available(self, cr, uid, ids, field_names=None, arg=False, context=None): """ Finds the incoming and outgoing quantity of product. @return: Dictionary of values """ if not field_names: field_names = [] if context is None: context = {} res = {} for id in ids: res[id] = {}.fromkeys(field_names, 0.0) for f in...
if m.product_qty * m.product_uom.factor > return_history[m.id]:
if m.product_qty * m.product_uom.factor >= return_history[m.id]:
def view_init(self, cr, uid, fields_list, context=None): """ Creates view dynamically and adding fields at runtime. @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 with new columns. """ res = sup...
'company_id': fields.many2one('res.company','Company',required=True,select=True),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial pickings and moves done. @param partial_datas: Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom """ res = {} picking_obj = self.pool.get('stock....
bro = obj_model.browse(self, cr, uid, res_id, context=context)
bro = obj_model.browse(cr, uid, res_id, context=context)
def __get_partner_id(self, cr, uid, res_model, res_id, context): """ A helper to retrieve the associated partner from any res_model+id It is a hack that will try to discover if the mentioned record is clearly associated with a partner record. """ obj_model = self.pool.get(res_model) if obj_model._name == 'res.partner':...
message_id = case.history_line[0].message_id
message_id = res_id
def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """
'balance_start': fields.function(_get_starting_balance, method=True, string='Opening Balance', type='float',digits=(16,2)), 'balance_end_real': fields.float('Closing Balance', digits=(16,2), states={'confirm':[('readonly', True)]}),
'balance_start': fields.function(_get_starting_balance, method=True, string='Opening Balance', type='float',digits=(16,2), help="Opening balance based on cashBox"), 'balance_end_real': fields.float('Closing Balance', digits=(16,2), states={'confirm':[('readonly', True)]}, help="closing balance entered by the cashbox ve...
def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users')
'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, string="Cash Transaction"),
'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, string="Cash Transaction", help="Total cash transactions"),
def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users')
'balance_end': fields.function(_end_balance, method=True, string='Balance'), 'balance_end_cash': fields.function(_balance_end_cash, method=True, string='Balance'),
'balance_end': fields.function(_end_balance, method=True, string='Balance', help="Closing balance based on transactions"), 'balance_end_cash': fields.function(_balance_end_cash, method=True, string='Balance', help="Closing balance based on cashBox"),
def _end_balance(self, cursor, user, ids, name, attr, context=None): res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users')
raise osv.except_osv(_('Error !'), _('Cash balance is not match with closing balance !'))
raise osv.except_osv(_('Error !'), _('Cash balance is not matching with closing balance !'))
def button_confirm(self, cr, uid, ids, context={}): """ Check the starting and ending detail of statement @return: True """ done = [] res_currency_obj = self.pool.get('res.currency') res_users_obj = self.pool.get('res.users') account_move_obj = self.pool.get('account.move') account_move_line_obj = self.pool.get('acco...
res[id] = sums[id]
res[id] = sums.get(id, null_result)
def __compute(self, cr, uid, ids, field_names, arg, context={}, query=''): #compute the balance/debit/credit accordingly to the value of field_name for the given account ids mapping = { 'balance': "COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance ", 'debit': "COALESCE(SUM(l.debit), 0) as debit ", 'credi...
for partner_id in ids: line_id = member_line_obj.search(cr, uid, [('partner', '=', partner_id)], limit=1, order='date_cancel') if line_id: res[partner_id] = member_line_obj.read(cr, uid, line_id[0], ['date_cancel'])['date_cancel']
for partner in self.browse(cr, uid, ids, context=context): if partner.membership_state != 'canceled': res[partner.id] = False
def _membership_cancel(self, cr, uid, ids, name, args, context=None): '''Return the cancel date of membership''' res = {} member_line_obj = self.pool.get('membership.membership_line') for partner_id in ids: line_id = member_line_obj.search(cr, uid, [('partner', '=', partner_id)], limit=1, order='date_cancel') if line_i...
res[partner_id] = False
line_id = member_line_obj.search(cr, uid, [('partner', '=', partner.id)],limit=1, order='date_cancel') if line_id: res[partner.id] = member_line_obj.read(cr, uid, line_id[0],['date_cancel'])['date_cancel'] else: res[partner.id] = False
def _membership_cancel(self, cr, uid, ids, name, args, context=None): '''Return the cancel date of membership''' res = {} member_line_obj = self.pool.get('membership.membership_line') for partner_id in ids: line_id = member_line_obj.search(cr, uid, [('partner', '=', partner_id)], limit=1, order='date_cancel') if line_i...
'date_open': fields.datetime('Opened', readonly=True),
def _compute_day(self, cr, uid, ids, fields, args, context=None): if context is None: context = {} """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Openday’s IDs @return: difference between current date and log date @param context: A st...
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'date_planned': date_planned,
def create_order(self, cr, uid, ids, context): """ To Create a purchase orders .
def write(self, cr, uid, ids, vals, context=None): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if context is None: context = {} res = super(project_phase, self).write(cr, uid, ids, vals, context=context) if context.g...
def write(self, cr, uid, ids, vals, context=None): resource_calendar_obj = self.pool.get('resource.calendar') resource_obj = self.pool.get('resource.resource') uom_obj = self.pool.get('product.uom') if context is None: context = {} res = super(project_phase, self).write(cr, uid, ids, vals, context=context) if context.g...
tax_obj = self.pool.get('account.tax')
tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency')
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for paym...
res[order.id]['amount_tax'] = reduce(lambda x, y: x+round(y['amount'], 2), tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * \ (1-(line.discount or 0.0)/100.0), line.qty)['taxes'], res[order.id]['amount_tax'])
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['amount'] res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
def _amount_all(self, cr, uid, ids, name, args, context=None): tax_obj = self.pool.get('account.tax') res={} for order in self.browse(cr, uid, ids): res[order.id] = { 'amount_paid': 0.0, 'amount_return':0.0, 'amount_tax':0.0, } for payment in order.statement_ids: res[order.id]['amount_paid'] += payment.amount for paym...
current_rec = self.read(cr, uid, ids, context)[0]
current_rec = self.read(cr, uid, ids, context)
def check_model(self, cr, uid, ids, context = None): if context is None: context = {} current_rec = self.read(cr, uid, ids, context)[0] if current_rec: model = self.pool.get(current_rec.get('object_id')[1]) if hasattr(model, 'message_new'): return True return False
model = self.pool.get(current_rec.get('object_id')[1])
current_rec = current_rec[0] model_name = self.pool.get('ir.model').browse(cr, uid, current_rec.get('object_id')[0]).model model = self.pool.get(model_name)
def check_model(self, cr, uid, ids, context = None): if context is None: context = {} current_rec = self.read(cr, uid, ids, context)[0] if current_rec: model = self.pool.get(current_rec.get('object_id')[1]) if hasattr(model, 'message_new'): return True return False
raise except_orm(_('Configuration Error!'),
raise orm.except_orm(_('Configuration Error!'),
def create(self, cr, uid, vals, context={}): try: res = super(account_invoice, self).create(cr, uid, vals, context) return res except Exception,e: if '"journal_id" viol' in e.args[0]: raise except_orm(_('Configuration Error!'), _('There is no Accounting Journal of type Sale/Purchase defined!')) else: raise except_orm(_...
raise except_orm(_('UnknownError'), str(e))
raise orm.except_orm(_('UnknownError'), str(e))
def create(self, cr, uid, vals, context={}): try: res = super(account_invoice, self).create(cr, uid, vals, context) return res except Exception,e: if '"journal_id" viol' in e.args[0]: raise except_orm(_('Configuration Error!'), _('There is no Accounting Journal of type Sale/Purchase defined!')) else: raise except_orm(_...
if not context:
if context is None:
def button_reset_taxes(self, cr, uid, ids, context=None): if not context: context = {} ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) partner = self.browse(cr, uid, id, context=context).partner_id if partner.lang: context.update({'l...
partner = self.browse(cr, uid, id, context=context).partner_id
partner = self.browse(cr, uid, id, context=ctx).partner_id
def button_reset_taxes(self, cr, uid, ids, context=None): if not context: context = {} ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) partner = self.browse(cr, uid, id, context=context).partner_id if partner.lang: context.update({'l...
context.update({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values():
ctx.update({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=ctx).values():
def button_reset_taxes(self, cr, uid, ids, context=None): if not context: context = {} ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) partner = self.browse(cr, uid, id, context=context).partner_id if partner.lang: context.update({'l...
self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context)
self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=ctx)
def button_reset_taxes(self, cr, uid, ids, context=None): if not context: context = {} ait_obj = self.pool.get('account.invoice.tax') for id in ids: cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) partner = self.browse(cr, uid, id, context=context).partner_id if partner.lang: context.update({'l...
if slip.move_id: if slip.move_id.state == 'posted': move_pool.button_cancel(cr, uid [slip.move_id.id], context) move_pool.unlink(cr, uid, [slip.move_id.id]) if slip.adj_move_id: if slip.adj_move_id.state == 'posted': move_pool.button_cancel(cr, uid [slip.adj_move_id.id], context) move_pool.unlink(cr, uid, [slip.adj_mo...
for line in slip.move_ids: if slip.move_id: if slip.move_id.state == 'posted': move_pool.button_cancel(cr, uid [slip.move_id.id], context) move_pool.unlink(cr, uid, [slip.move_id.id])
def cancel_sheet(self, cr, uid, ids, context={}): move_pool = self.pool.get('account.move')
contract = cr.dictfetchone()
contract = cr.dictfetchone() contract = contract and contract or {}
def get_contract(self, cr, uid, employee, date, context={}): sql_req= ''' SELECT c.id as id, c.wage as wage, struct_id as function FROM hr_contract c LEFT JOIN hr_employee emp on (c.employee_id=emp.id) LEFT JOIN hr_contract_wage_type cwt on (cwt.id = c.wage_type_id) LEFT JOIN hr_contract_wage_type_period p on (cwt.peri...
basic_before_leaves = basic
if not slip.contract_id : continue basic_before_leaves = slip.basic
def get_days(start, end, month, year, calc_day): count = 0 import datetime for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count
)""", (line.planning_id.id,line.account_id.id ))
)""", (line.planning_id.id, line.account_id and line.account_id.id or None))
def _get_tasks(self, cr, uid, ids, name, args, context=None): if context is None: context = {} users_obj = self.pool.get('res.users') result = {} tm = users_obj.browse(cr, uid, uid, context).company_id.project_time_mode_id if tm and tm.factor: div = tm.factor else: div = 1.0 tm2 = users_obj.browse(cr, uid, uid, context...
WHERE acc.date>=%s and acc.date<=%s and acc.account_id=%s""", (line.planning_id.date_from, line.planning_id.date_to, line.account_id.id, ))
WHERE acc.date>=%s and acc.date<=%s and acc.account_id=%s""", (line.planning_id.date_from, line.planning_id.date_to, line.account_id and line.account_id.id or None))
def _get_timesheets(self, cr, uid, ids, name, args, context=None): if context is None: context = {} users_obj = self.pool.get('res.users') result = {} tm2 = users_obj.browse(cr, uid, uid, context).company_id.planning_time_mode_id if tm2 and tm2.factor: div2 = tm2.factor else: div2 = 1.0 for line in self.browse(cr, uid,...
WHERE user_id=%s and account_id=%s and date>=%s and date<=%s''', (line.user_id.id, line.account_id.id, line.planning_id.date_from, line.planning_id.date_to))
WHERE user_id=%s and account_id=%s and date>=%s and date<=%s''', (line.user_id.id, line.account_id and line.account_id.id or None, line.planning_id.date_from, line.planning_id.date_to))
def _sum_amount_real(self, cr, uid, ids, name, args, context=None): if context is None: context = {} users_obj = self.pool.get('res.users') result = {} tm2 = users_obj.browse(cr, uid, uid, context).company_id.planning_time_mode_id if tm2 and tm2.factor: div2 = tm2.factor else: div2 = 1.0 for line in self.browse(cr, uid...
cr.execute('SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s', (line.account_id.id, line.planning_id.date_from, line.planning_id.date_to))
cr.execute('SELECT sum(unit_amount) FROM account_analytic_line WHERE account_id=%s AND date>=%s AND date<=%s', (line.account_id and line.account_id.id or None, line.planning_id.date_from, line.planning_id.date_to))
def _sum_amount_real(self, cr, uid, ids, name, args, context=None): if context is None: context = {} users_obj = self.pool.get('res.users') result = {} tm2 = users_obj.browse(cr, uid, uid, context).company_id.planning_time_mode_id if tm2 and tm2.factor: div2 = tm2.factor else: div2 = 1.0 for line in self.browse(cr, uid...
line.account_id.id,
line.account_id and line.account_id.id or None,
def _sum_amount_tasks(self, cr, uid, ids, name, args, context=None): if context is None: context = {} users_obj = self.pool.get('res.users') result = {} tm = users_obj.browse(cr, uid, uid, context).company_id.project_time_mode_id if tm and tm.factor: div = tm.factor else: div = 1.0 tm2 = users_obj.browse(cr, uid, uid, ...
for (user_id, box_id, amount) in res: cashmove_ref.create(cr, uid, { 'name': 'Summary for user' + str(user_id), 'amount': amount, 'user_cashmove': user_id, 'box': box_id, 'active': True, })
def set_to_zero(self, cr, uid, ids, context):
self.write(cr,uid,ids,{'amount':total}) self.write(cr, uid, ids, {'state':'proforma'})
if total!=0: self.write(cr,uid,ids,{'amount':total}) self.write(cr, uid, ids, {'state':'proforma'}) else: raise osv.except_osv('Invalid action !', 'You can not post to Pro-Forma a voucher with Total amount = 0')
def open_voucher(self, cr, uid, ids, context={}): obj=self.pool.get('account.voucher').browse(cr,uid,ids) total=0 for i in obj[0].payment_ids: total+=i.amount self.write(cr,uid,ids,{'amount':total}) self.write(cr, uid, ids, {'state':'proforma'}) return True
raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !')
raise osv.except_osv('Invalid action !', 'Cannot delete Voucher(s) which are already opened or paid !')
def unlink(self, cr, uid, ids, context={}): vouchers = self.read(cr, uid, ids, ['state']) unlink_ids = [] for t in vouchers: if t['state'] in ('draft', 'cancel'): unlink_ids.append(t['id']) else: raise osv.except_osv('Invalid action !', 'Cannot delete invoice(s) which are already opened or paid !') osv.osv.unlink(self,...
return 'l10n_ch', 'action_account_dtr_create_values'
return 'l10n_ch', 'action_dta_create'
def get_wizard(self,mode): if mode == 'dta': return 'l10n_ch', 'action_account_dtr_create_values'
'domain': [('res_id','in',ids),('res_model','=',self._name)],
'domain': [('res_id','=',message_pool.res_id),('res_model','=',message_pool.model)],
def open_attachment(self, cr, uid, ids, context): """ To Open attachments @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: the ID of messages @param context: A standard dictionary """ action_data = False action_pool = self.pool.get('ir.actions.act_...
case = pool.get('crm.case').browse(cr,uid,data['ids'])[0]
case = pool.get('crm.lead').browse(cr, uid, data['id'])
def _get_info(self, cr, uid, data, context): if not data['id']: return {} pool = pooler.get_pool(cr.dbname) case = pool.get('crm.case').browse(cr,uid,data['ids'])[0] #if not case.email_from: # raise wizard.except_wizard(_('Error'),_('You must put a Partner eMail to use this action!')) if not case.user_id: raise wiza...
return _('The IBAN does not seems to be correct. You should have entered something like this %s'), (iban_example)
return _('The IBAN does not seem to be correct. You should have entered something like this %s'), (iban_example)
def default_iban_check(iban_cn): return iban_cn[0] in string.ascii_lowercase and iban_cn[1] in string.ascii_lowercase
if context.get('period_from', False) and context.get('periof_from', False) and not context.get('periods', False):
if context.get('period_from', False) and context.get('period_to', False) and not context.get('periods', False):
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = ...
period_company_id = period_obj.browse(cr, uid, data['form']['period_from'], context=context).company_id.id first_period = self.pool.get('account.period').search(cr, uid, [('company_id', '=', period_company_id)], order='date_start', limit=1)[0] context['periods'] = period_obj.build_ctx_periods(cr, uid, first_period, dat...
period_company_id = fiscalperiod_obj.browse(cr, uid, context['period_from'], context=context).company_id.id first_period = fiscalperiod_obj.search(cr, uid, [('company_id', '=', period_company_id)], order='date_start', limit=1)[0] context['periods'] = fiscalperiod_obj.build_ctx_periods(cr, uid, first_period, context['pe...
def _query_get(self, cr, uid, obj='l', context={}): fiscalyear_obj = self.pool.get('account.fiscalyear') fiscalperiod_obj = self.pool.get('account.period') fiscalyear_ids = [] fiscalperiod_ids = [] initial_bal = context.get('initial_bal', False) company_clause = "" if context.get('company_id', False): company_clause = ...
fld.append((field.field, field.sequence))
fld.append((field.field, field.sequence, field.name))
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal')
fld.append(('period_id', 3)) fld.append(('journal_id', 10))
fld.append(('period_id', 3, 'Period')) fld.append(('journal_id', 10, 'Journal'))
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal')
attrs.append('string="'+field_it[2]+'"')
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): journal_pool = self.pool.get('account.journal')
'company_id': fields.related('partner_id','company_id',type='many2one',relation='res.company',string='Company', store=True),
'company_id': fields.many2one('res.company', 'Company',select=1),
def view_header_get(self, cr, uid, view_id, view_type, context): res = super(res_partner, self).view_header_get(cr, uid, view_id, view_type, context) if res: return res if (not context.get('category_id', False)): return False return _('Partners: ')+self.pool.get('res.partner.category').browse(cr, uid, context['category...
date_invoice=False, payment_term=False, partner_bank_id=False):
date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):
def onchange_partner_id(self, cr, uid, ids, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False): """ Function that is call when the partner of the invoice is changed it will retriev and set the good bank partner bank""" res = super(account_invoice, self).onchange_partner_id( cr, uid, ids, t...
qty=0, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name,
def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False): res = self.product_id_change(cursor, user, ids, pricelist, product, qty=0, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partn...
price = line.price_unit * line.product_uom_qty * (1 - (line.discount or 0.0) / 100.0) taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty)
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
def _amount_line(self, cr, uid, ids, field_name, arg, context=None): tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') res = {} context = context or {} for line in self.browse(cr, uid, ids, context=context): price = line.price_unit * line.product_uom_qty * (1 - (line.discount or 0.0) / 100....
ds = ds + RelativeDateTime(days=interval) + 1
new_id = period_obj.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)
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] 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.st...
ds = ds + RelativeDateTime(months=interval) lines.append(period_obj.create(cr, uid, {
new_id =period_obj.create(cr, uid, {
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] 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.st...
}))
}) ds = ds + RelativeDateTime(months=interval) lines.append(new_id)
def create_stock_periods(self, cr, uid, ids, context=None): interval = context.get('interval',0) name = context.get('name','Daily') period_obj = self.pool.get('stock.period') lines = [] 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.st...
if jt == 'sale':
if jt in ('sale', 'purchase_refund'):
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False): val = {} val['date_maturity'] = False
elif jt == 'purchase':
elif jt in ('purchase', 'sale_refund', 'expense'):
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False): val = {} val['date_maturity'] = False
if field in ('amount_currency','currency_id'):
elif field == 'statement_id': attrs.append("domain=\"[('state','!=','confirm'),('journal_id.type','=','bank')]\"") if field in ('amount_currency', 'currency_id'):
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id,view_type,context,toolbar=toolbar, submenu=submenu) if view_type != 'tree': return result
'user' : self.pool.get('res.users').browse(cr, uid, uid, context=context)
'user' : self.pool.get('res.users').browse(cr, uid, uid, context=context),
def do_action(self, cr, uid, action, model_obj, obj, context=None): """ Do Action @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param action: pass action @param model_obj: pass Model object @param context: A standard diction...