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_id': ol.account_analytic_id.id, })
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+'): StringIO.__init__(self, None) # at write, we start at 0 (= overwrite), but have the original # data available, in case of a seek() elif mode == 'a': StringIO.__init__(self, None) else: logging.getLogger('document.storage').error("Incorrect mode %s specified", mode) raise IOError(errno.EINVAL, "Invalid file mode") self.mode = mode
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 SET db_datas = decode(%s,'escape'), file_size=%s WHERE id = %s", (out, len(out), par.file_id)) elif self.mode == 'a': out = self.getvalue() cr.execute("UPDATE ir_attachment " \ "SET db_datas = COALESCE(db_datas,'') || decode(%s, 'escape'), " \ " file_size = COALESCE(file_size, 0) + %s " \ " WHERE id = %s", (out, len(out), par.file_id)) cr.commit() except Exception, e: logging.getLogger('document.storage').exception('Cannot update db file #%d for close:', par.file_id) raise finally: cr.close() StringIO.close(self)
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 SET db_datas = decode(%s,'escape'), file_size=%s WHERE id = %s", (out, len(out), par.file_id)) elif self.mode == 'a': out = self.getvalue() cr.execute("UPDATE ir_attachment " \ "SET db_datas = COALESCE(db_datas,'') || decode(%s, 'escape'), " \ " file_size = COALESCE(file_size, 0) + %s " \ " WHERE id = %s", (out, len(out), par.file_id)) cr.commit() except Exception, e: logging.getLogger('document.storage').exception('Cannot update db file #%d for close:', par.file_id) raise finally: cr.close() StringIO.close(self)
"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 SET db_datas = decode(%s,'escape'), file_size=%s WHERE id = %s", (out, len(out), par.file_id)) elif self.mode == 'a': out = self.getvalue() cr.execute("UPDATE ir_attachment " \ "SET db_datas = COALESCE(db_datas,'') || decode(%s, 'escape'), " \ " file_size = COALESCE(file_size, 0) + %s " \ " WHERE id = %s", (out, len(out), par.file_id)) cr.commit() except Exception, e: logging.getLogger('document.storage').exception('Cannot update db file #%d for close:', par.file_id) raise finally: cr.close() StringIO.close(self)
(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 SET db_datas = decode(%s,'escape'), file_size=%s WHERE id = %s", (out, len(out), par.file_id)) elif self.mode == 'a': out = self.getvalue() cr.execute("UPDATE ir_attachment " \ "SET db_datas = COALESCE(db_datas,'') || decode(%s, 'escape'), " \ " file_size = COALESCE(file_size, 0) + %s " \ " WHERE id = %s", (out, len(out), par.file_id)) cr.commit() except Exception, e: logging.getLogger('document.storage').exception('Cannot update db file #%d for close:', par.file_id) raise finally: cr.close() StringIO.close(self)
(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 = fil_obj else: ira = self.pool.get('ir.attachment').browse(cr, uid, file_node.file_id, context=context)
'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, sequence_id, 'id', context=tmp_context) else: number = self.pool.get('ir.sequence').get_id(cr, uid, 'account.invoice.%s' % invtype, 'code', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) message = _('Invoice ') + " '" + number + "' "+ _("is confirm") self.log(cr, uid, id, message) return True
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 } 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, sequence_id, 'id', context=tmp_context) else: number = self.pool.get('ir.sequence').get_id(cr, uid, 'account.invoice.%s' % invtype, 'code', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) message = _('Invoice ') + " '" + number + "' "+ _("is confirm") self.log(cr, uid, id, message) return True
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).get('account.tax').browse(self.cr, self.uid, tax_ids)] return ",\n ".join(res)
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_ids = [t[0] for t in res] else: tax_ids = res[0] tax_obj = pooler.get_pool(cr.dbname).get('account.tax') res = [] for tax in tax_obj.browse(self.cr, self.uid, tax_ids): self.cr.execute("SELECT DISTINCT order_line_id FROM purchase_order_line, purchase_order_taxe \ WHERE (purchase_order_taxe.tax_id=%s) AND (purchase_order_line.order_id=%s)", (tax.id, order_obj.id)) lines = self.cr.fetchall() or None if lines: if isinstance(lines, list): line_ids = [l[0] for l in lines] else: line_ids = lines[0] base = 0 for line in pooler.get_pool(cr.dbname).get('purchase.order.line').browse(self.cr, self.uid, line_ids): base += line.price_subtotal res.append({'code':tax.name, 'base':base, 'amount':base*tax.amount}) return res
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_ids = [t[0] for t in res] else: tax_ids = res[0] tax_obj = pooler.get_pool(cr.dbname).get('account.tax') res = [] for tax in tax_obj.browse(self.cr, self.uid, tax_ids): self.cr.execute("SELECT DISTINCT order_line_id FROM purchase_order_line, purchase_order_taxe \ WHERE (purchase_order_taxe.tax_id=%s) AND (purchase_order_line.order_id=%s)", (tax.id, order_obj.id)) lines = self.cr.fetchall() or None if lines: if isinstance(lines, list): line_ids = [l[0] for l in lines] else: line_ids = lines[0] base = 0 for line in pooler.get_pool(cr.dbname).get('purchase.order.line').browse(self.cr, self.uid, line_ids): base += line.price_subtotal res.append({'code':tax.name, 'base':base, 'amount':base*tax.amount}) return res
'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_id = context and context.get('active_id', False) or False move_obj = self.pool.get('stock.move') pick_obj = self.pool.get('stock.picking') uom_obj = self.pool.get('product.uom') wf_service = netsvc.LocalService("workflow") pick = pick_obj.browse(cr, uid, record_id) data = self.read(cr, uid, ids[0]) new_picking = None date_cur = time.strftime('%Y-%m-%d %H:%M:%S') set_invoice_state_to_none = True returned_lines = 0 for move in pick.move_lines: if not new_picking: if pick.type=='out': new_type = 'in' elif pick.type=='in': new_type = 'out' else: new_type = 'internal' new_picking = pick_obj.copy(cr, uid, pick.id, {'name':'%s (return)' % pick.name, 'move_lines':[], 'state':'draft', 'type':new_type, 'date':date_cur, 'invoice_state':data['invoice_state'],}) new_location=move.location_dest_id.id if move.state=='done': new_qty = data['return%s' % move.id] returned_qty = move.product_qty for rec in move.move_history_ids2: returned_qty -= rec.product_qty if returned_qty != new_qty: set_invoice_state_to_none = False
_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: calendar_id = project.resource_calendar_id.id resource_leave_ids = pooler.get_pool(cr.dbname).get('resource.calendar.leaves').search(cr,uid,[('calendar_id','=',project.resource_calendar_id.id)])
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.variants if not data['code']: data['code'] = p.code if not data['name']: data['name'] = p.name res[p.id] = (data['code'] and ('['+data['code']+'] ') or '') + \ (data['name'] or '') + (data['variants'] and (' - '+data['variants']) or '') return res
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, time zone @return: Returns a dict which contains new values, and context """ if not journal_id: return {} move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') default = { 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False}, }
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, time zone @return: Returns a dict which contains new values, and context """ if not journal_id: return {} move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') default = { 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False}, }
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, time zone @return: Returns a dict which contains new values, and context """ if not journal_id: return {} move_pool = self.pool.get('account.move') line_pool = self.pool.get('account.voucher.line') move_line_pool = self.pool.get('account.move.line') partner_pool = self.pool.get('res.partner') journal_pool = self.pool.get('account.journal') default = { 'value':{'line_ids':[], 'line_dr_ids':[], 'line_cr_ids':[], 'pre_line': False}, }
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 partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue 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)]} else: journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]}
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 Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]}
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 partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue 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)]} else: journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]}
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 partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) if not rec_pro_id: rec_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = self.pool.get('ir.property').search(cr,uid,[('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = self.pool.get('ir.property').read(cr,uid,rec_pro_id,['name','value','res_id']) pay_line_data = self.pool.get('ir.property').read(cr,uid,pay_pro_id,['name','value','res_id']) rec_res_id = rec_line_data and int(rec_line_data[0]['value'].split(',')[1]) or False pay_res_id = pay_line_data and int(pay_line_data[0]['value'].split(',')[1]) or False if not rec_res_id and not rec_res_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company, Please Create account.')) if type in ('out_invoice', 'out_refund'): acc_id = rec_res_id else: acc_id = pay_res_id val= {'account_id': acc_id} if ids: if company_id: inv_obj = self.browse(cr,uid,ids) for line in inv_obj[0].invoice_line: if line.account_id: if line.account_id.company_id.id != company_id: result_id = self.pool.get('account.account').search(cr,uid,[('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configration Error !'), _('Can not find account chart for this company in invoice line account, Please Create account.')) r_id = self.pool.get('account.invoice.line').write(cr,uid,[line.id],{'account_id': result_id[0]}) else: if invoice_line: for inv_line in invoice_line: obj_l = self.pool.get('account.account').browse(cr,uid,inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configration Error !'), _('invoice line account company is not match with invoice company.')) else: continue 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)]} else: journal_ids=self.pool.get('account.journal').search(cr,uid,[]) dom={'journal_id': [('id','in',journal_ids)]}
'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['plugin_file'] = base64.encodestring(file.read()) return 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 'id' in datas: datas['id'] = caldevIDs2readIDs(datas['id']) for id in datas['ids']: new_ids.append(caldevIDs2readIDs(id)) datas['ids'] = new_ids res=super(virtual_wizard, self).exp_execute(db, uid, wiz_id, datas, action, context) return res
'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'), 'delivery': _('Delivery order') } new_id = super(stock_picking, self).create(cr, user, vals, context) if not vals.get('auto_picking', False): message = type_list.get(vals.get('type', False), _('Picking')) + " '" + (vals.get('name', 'n/a')) + _(" with origin")+" '" + vals.get('origin', 'n/a') + "' "+ _("is created.") self.log(cr, user, new_id, message) return new_id
('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 field_names: c = context.copy() if f == 'qty_available': c.update({ 'states': ('done',), 'what': ('in', 'out') }) if f == 'virtual_available': c.update({ 'states': ('confirmed','waiting','assigned','done'), 'what': ('in', 'out') }) if f == 'incoming_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('in',) }) if f == 'outgoing_qty': c.update({ 'states': ('confirmed','waiting','assigned'), 'what': ('out',) }) stock = self.get_product_available(cr, uid, ids, context=c) for id in ids: res[id][f] = stock.get(id, 0.0) return res
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 = super(stock_return_picking, self).view_init(cr, uid, fields_list, context=context) record_id = context and context.get('active_id', False) if record_id: pick_obj = self.pool.get('stock.picking') pick = pick_obj.browse(cr, uid, record_id) if pick.state not in ['done','confirmed','assigned']: raise osv.except_osv(_('Warning !'), _("You may only return pickings that are Confirmed, Available or Done!")) return_history = {} valid_lines = 0 for m in [line for line in pick.move_lines]: if m.state == 'done': return_history[m.id] = 0 for rec in m.move_history_ids2: return_history[m.id] += (rec.product_qty * rec.product_uom.factor) if m.product_qty * m.product_uom.factor > return_history[m.id]: valid_lines += 1 if 'return%s'%(m.id) not in self._columns: self._columns['return%s'%(m.id)] = fields.float(string=m.name, required=True) if 'invoice_state' not in self._columns: self._columns['invoice_state'] = fields.selection([('2binvoiced', 'To be refunded/invoiced'), ('none', 'No invoicing')], string='Invoicing', required=True) if not valid_lines: raise osv.except_osv(_('Warning !'), _("There are no products to return (only lines in Done state and not fully returned yet can be returned)!")) return res
'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.picking') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') uom_obj = self.pool.get('product.uom') wf_service = netsvc.LocalService("workflow")
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': return res_id elif 'partner_id' in obj_model._columns and obj_model._columns['partner_id']._obj == 'res.partner': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.partner_id.id elif 'address_id' in obj_model._columns and obj_model._columns['address_id']._obj == 'res.partner.address': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.address_id.partner_id.id return False
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 verifier"),
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('account.move.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
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 ", 'credit': "COALESCE(SUM(l.credit), 0) as credit " } #get all the necessary accounts ids2 = self._get_children_and_consol(cr, uid, ids, context) #compute for each account the balance/debit/credit from the move lines accounts = {} if ids2: aml_query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
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_id: res[partner_id] = member_line_obj.read(cr, uid, line_id[0], ['date_cancel'])['date_cancel'] else: res[partner_id] = False return res
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_id: res[partner_id] = member_line_obj.read(cr, uid, line_id[0], ['date_cancel'])['date_cancel'] else: res[partner_id] = False return res
'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 standard dictionary for contextual values """ cal_obj = self.pool.get('resource.calendar') res_obj = self.pool.get('resource.resource')
'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.get('scheduler',False): return res if isinstance(ids, (int, long)): ids = [ids] default_uom_id = self._get_default_uom_id(cr, uid) for phase in self.browse(cr, uid, ids, context=context): calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False resource_id = resource_obj.search(cr, uid, [('user_id', '=', phase.responsible_id.id)],context=context) if resource_id: cal_id = resource_obj.browse(cr, uid, resource_id[0], context=context).calendar_id.id if cal_id: calendar_id = cal_id avg_hours = uom_obj._compute_qty(cr, uid, phase.product_uom.id, phase.duration, default_uom_id) if vals.get('date_start', False) and vals['date_start'] < phase.date_start: dt_start = datetime.strptime(vals['date_start'], '%Y-%m-%d') work_times = resource_calendar_obj.interval_get(cr, uid, calendar_id, dt_start, avg_hours or 0.0, resource_id and resource_id[0] or False) if work_times: vals['date_end'] = work_times[-1][1].strftime('%Y-%m-%d') for prv_phase in phase.previous_phase_ids: if prv_phase.id == phase.id: continue self._check_date_start(cr, uid, prv_phase, dt_start, context=context) if vals.get('date_end', False) and vals['date_end'] > phase.date_end: dt_end = datetime.strptime(vals['date_end'], '%Y-%m-%d') work_times = resource_calendar_obj.interval_min_get(cr, uid, calendar_id, dt_end, avg_hours or 0.0, resource_id and resource_id[0] or False) if work_times: vals['date_start'] = work_times[0][0].strftime('%Y-%m-%d') for next_phase in phase.next_phase_ids: if next_phase.id == phase.id: continue self._check_date_end(cr, uid, next_phase, dt_end, context=context) return res
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.get('scheduler',False): return res # Consider calendar and efficiency if the phase is performed by a resource # otherwise consider the project's working calendar
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 payment in order.payments: 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']) else: 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']) return res
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 payment in order.payments: 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']) else: 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']) return res
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(_('UnknownError'), str(e))
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(_('UnknownError'), str(e))
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({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values(): ait_obj.create(cr, uid, taxe) # Update the stored value (fields.function), so we write to trigger recompute self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context) return True
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({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values(): ait_obj.create(cr, uid, taxe) # Update the stored value (fields.function), so we write to trigger recompute self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context) return True
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({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values(): ait_obj.create(cr, uid, taxe) # Update the stored value (fields.function), so we write to trigger recompute self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context) return True
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({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=context).values(): ait_obj.create(cr, uid, taxe) # Update the stored value (fields.function), so we write to trigger recompute self.pool.get('account.invoice').write(cr, uid, ids, {'invoice_line':[]}, context=context) return True
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_move_id.id]) if slip.other_move_id: if slip.other_move_id.state == 'posted': move_pool.button_cancel(cr, uid [slip.other_move_id.id], context) move_pool.unlink(cr, uid, [slip.other_move_id.id])
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.period_id = p.id) WHERE (emp.id=%s) AND (date_start <= %s) AND (date_end IS NULL OR date_end >= %s) LIMIT 1 ''' cr.execute(sql_req, (employee.id, date, date)) contract = cr.dictfetchone() return contract
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).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, ids, context): cr.execute(""" SELECT COALESCE(sum(tasks.remaining_hours),0) FROM project_task tasks WHERE tasks.planning_line_id IN ( SELECT id FROM report_account_analytic_planning_line WHERE planning_id = %s AND account_id=%s )""", (line.planning_id.id,line.account_id.id )) result[line.id] = cr.fetchall()[0][0] / div * div2 return result
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, ids, context): cr.execute(""" SELECT SUM(unit_amount/uom.factor) FROM account_analytic_line acc LEFT JOIN product_uom uom ON (uom.id = acc.product_uom_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.id, )) res = cr.fetchall()[0][0] if res: result[line.id] = res * div2 else: result[line.id] = 0 return result
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, ids, context): if line.user_id: cr.execute('''SELECT sum(acc.unit_amount/uom.factor) FROM account_analytic_line acc LEFT JOIN product_uom uom ON (uom.id = acc.product_uom_id)
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, ids, context): if line.user_id: cr.execute('''SELECT sum(acc.unit_amount/uom.factor) FROM account_analytic_line acc LEFT JOIN product_uom uom ON (uom.id = acc.product_uom_id)
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, 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, ids, context): where = '' if line.user_id: where = 'user_id=' + str(line.user_id.id) + ' and ' cr.execute('''select sum(planned_hours) FROM project_task WHERE ''' + where + ''' project_id IN (select id from project_project where analytic_account_id=%s) AND date_end>=%s AND date_end<=%s''', ( line.account_id.id, line.planning_id.date_from, line.planning_id.date_to) ) sum = cr.fetchone() if sum and sum[0]: result[line.id] = sum[0] /div * div2 return result
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, cr, uid, unlink_ids) return True
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_window') action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')]) if action_ids: action_data = action_pool.read(cr, uid, action_ids[0], context=context) action_data.update({ 'domain': [('res_id','in',ids),('res_model','=',self._name)], 'nodestroy': True }) return action_data
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 wizard.except_wizard(_('Error'),_('You must define a responsible user for this case in order to use this action!')) return {'to': case.email_from,'subject': case.name,'cc': case.email_cc or ''}
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 = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
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, data['form']['period_from']) else: context['periods'] = period_obj.build_ctx_periods(cr, uid, data['form']['period_from'], data['form']['period_to'])
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['period_from']) else: context['periods'] = fiscalperiod_obj.build_ctx_periods(cr, uid, context['period_from'], context['period_to'])
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 = " AND " +obj+".company_id = %s" % context.get('company_id', False) if not context.get('fiscalyear', False): fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: if initial_bal: fiscalyear_date_start = fiscalyear_obj.read(cr, uid, context['fiscalyear'], ['date_start'])['date_start'] fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('date_stop', '<', fiscalyear_date_start), ('state', '=', 'draft')], context=context) else: fiscalyear_ids = [context['fiscalyear']]
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_id'], context).name
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, type, partner_id, date_invoice, payment_term ) bank_id = False if partner_id: p = self.pool.get('res.partner').browse(cr, uid, partner_id) if p.bank_ids: bank_id = p.bank_ids[0].id
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=partner_id, lang=lang, update_tax=update_tax, date_order=date_order) if 'product_uom' in res['value']: del res['value']['product_uom'] if not uom: res['value']['price_unit'] = 0.0 return res
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.0) taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty) cur = line.order_id.pricelist_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, taxes['total']) return res
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.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + RelativeDateTime(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') ds = ds + RelativeDateTime(days=interval) + 1 if name =="Weekly": de = ds + RelativeDateTime(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') ds = ds + RelativeDateTime(days=interval) + 1 if name == "Monthly": de = ds + RelativeDateTime(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') ds = ds + RelativeDateTime(months=interval) lines.append(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'), })) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
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.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + RelativeDateTime(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') ds = ds + RelativeDateTime(days=interval) + 1 if name =="Weekly": de = ds + RelativeDateTime(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') ds = ds + RelativeDateTime(days=interval) + 1 if name == "Monthly": de = ds + RelativeDateTime(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') ds = ds + RelativeDateTime(months=interval) lines.append(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'), })) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
}))
}) 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.strftime('%Y-%m-%d') < p.date_stop: if name =='Daily': de = ds + RelativeDateTime(days=interval, minutes =-1) new_name = de.strftime('%Y-%m-%d') ds = ds + RelativeDateTime(days=interval) + 1 if name =="Weekly": de = ds + RelativeDateTime(days=interval, minutes =-1) new_name = de.strftime('%Y, week %W') ds = ds + RelativeDateTime(days=interval) + 1 if name == "Monthly": de = ds + RelativeDateTime(months=interval, minutes=-1) new_name = ds.strftime('%Y/%m') ds = ds + RelativeDateTime(months=interval) lines.append(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'), })) return { 'domain': "[('id','in', ["+','.join(map(str, lines))+"])]", 'view_type': 'form', "view_mode": 'tree, form', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
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 dictionary for contextual values """ if context is None: context = {}