rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
'note': line.name, | 'note': _('Picking for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s ( | def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) |
'note': line.name, | 'note': _('Move for pulled procurement coming from original location %s, pull rule %s, via original Procurement %s ( | def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) |
self.write(cr, uid, [proc.id], {'state':'running','message':_('Moved from other location')}) | wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr) | def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') picking_obj=self.pool.get('stock.picking') wf_service = netsvc.LocalService("workflow") for proc in proc_obj.browse(cr, uid, ids, context=context): line = None for line in proc.product_id.flow_pull_ids: if line.location_id==proc.location_id: break assert line, 'Line can not be False if we are on this state of the workflow' origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name picking_id =picking_obj.create(cr, uid, { 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'type': line.picking_type, 'stock_journal_id': line.journal_id and line.journal_id.id or False, 'move_type': 'one', 'address_id': line.partner_address_id.id, 'note': line.name, # TODO: note on procurement ? 'invoice_state': line.invoice_state, }) move_id =move_obj.create(cr, uid, { 'name': line.name, 'picking_id': picking_id, 'company_id': line.company_id and line.company_id.id or False, 'product_id': proc.product_id.id, 'date': proc.date_planned, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'address_id': line.partner_address_id.id, 'location_id': line.location_src_id.id, 'location_dest_id': line.location_id.id, 'move_dest_id': proc.move_id and proc.move_id.id or False, # to verif, about history ? 'tracking_id': False, 'cancel_cascade': line.cancel_cascade, 'state': 'confirmed', 'note': line.name, # TODO: same as above }) if proc.move_id and proc.move_id.state in ('confirmed'): move_obj.write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = proc_obj.create(cr, uid, { 'name': line.name, 'origin': origin, 'company_id': line.company_id and line.company_id.id or False, 'date_planned': proc.date_planned, 'product_id': proc.product_id.id, 'product_qty': proc.product_qty, 'product_uom': proc.product_uom.id, 'product_uos_qty': (proc.product_uos and proc.product_uos_qty)\ or proc.product_qty, 'product_uos': (proc.product_uos and proc.product_uos.id)\ or proc.product_uom.id, 'location_id': line.location_src_id.id, 'procure_method': line.procure_method, 'move_id': move_id, }) wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr) wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr) if proc.move_id: move_obj.write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id}) |
if line.account_id.currency_id: if line.account_id.currency_id.id != line.currency_id.id and (line.account_id.currency_id.id != line.account_id.company_id.currency_id.id or line.currency_id): | if line.account_id.currency_id and line.currency_id: if line.account_id.currency_id.id != line.currency_id.id and (line.account_id.currency_id.id != line.account_id.company_id.currency_id.id): | def validate(self, cr, uid, ids, context={}): if context and ('__last_update' in context): del context['__last_update'] |
if product_obj.price_unit_id.coefficient != 1.0: | if product_obj.price_unit_id and product_obj.price_unit_id.coefficient != 1.0: | def product_id_change(self, cr, uid, ids, pricelist, price_unit_id, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id} |
purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price':purchase_price}) | if product: purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price':purchase_price}) | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): res = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag) purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price':purchase_price}) return res |
company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] | if vals.get('move_id', False): company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] | def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj = self.pool.get('account.tax') move_obj = self.pool.get('account.move') cur_obj = self.pool.get('res.currency') journal_obj = self.pool.get('account.journal') if context is None: context = {} company_id = self.pool.get('account.move').read(cr, uid, vals['move_id'], ['company_id']).get('company_id', False) if company_id: vals['company_id'] = company_id[0] self._check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['active']: raise osv.except_osv(_('Bad account!'), _('You can not use an inactive account!')) if 'journal_id' in vals: context['journal_id'] = vals['journal_id'] if 'period_id' in vals: context['period_id'] = vals['period_id'] if ('journal_id' not in context) and ('move_id' in vals) and vals['move_id']: m = move_obj.browse(cr, uid, vals['move_id']) context['journal_id'] = m.journal_id.id context['period_id'] = m.period_id.id |
message_id = case.history_line[0].message_id | if len(case.history_line): message_id = case.history_line[0].message_id | def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """ |
'References':"%s" % (message_id), | def action_send(self, cr, uid, ids, context=None): """ This sends an email to ALL the addresses of the selected partners. """ |
|
getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue()) | getattr(self.pool.get('document.directory.content'), 'process_write')(cr, self.uid, self.node, self.getvalue()) | def close(self, *args, **kwargs): db,pool = pooler.get_db_and_pool(self.dbname) cr = db.cursor() cr.commit() try: getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue()) finally: cr.commit() cr.close() StringIO.StringIO.close(self, *args, **kwargs) |
res[order.id] = min(dates_list) | if dates_list: res[order.id] = min(dates_list) | def _get_commitment_date(self, cr, uid, ids, name, arg, context={}): res = {} dates_list = [] for order in self.browse(cr, uid, ids): dates_list = [] for line in order.order_line: dt=DateTime.strptime(order.date_order, '%Y-%m-%d') + DateTime.RelativeDateTime(days=line.delay or 0.0) dt_s = dt.strftime('%Y-%m-%d') dates_list.append(dt_s) res[order.id] = min(dates_list) return res |
company_id=self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context) | company_id=self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=context) | def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, unit, context={}): res = {} |
def _query_get(self, cr, uid, obj='l', context={}): | def _query_get(self, cr, uid, obj='l', context=None): | 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']] |
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date < '"+context['date_from']+"')" | where_move_lines_by_date = " OR " +obj+".move_id in ( select id from account_move where date < '"+context['date_from']+"')" | 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']] |
required=True, select=True), | required=True, select=True, ondelete='cascade'), | def price_get(self, cr, uid, ids, prod_id, qty, partner=None, context=None): ''' context = { 'uom': Unit of Measure (int), 'partner': Partner ID (int), 'date': Date of the pricelist (%Y-%m-%d), } ''' context = context or {} currency_obj = self.pool.get('res.currency') product_obj = self.pool.get('product.product') supplierinfo_obj = self.pool.get('product.supplierinfo') price_type_obj = self.pool.get('product.price.type') |
'price_version_id': fields.many2one('product.pricelist.version', 'Price List Version', required=True, select=True), | 'price_version_id': fields.many2one('product.pricelist.version', 'Price List Version', required=True, select=True, ondelete='cascade'), | def _check_recursion(self, cr, uid, ids): for obj_list in self.browse(cr, uid, ids): if obj_list.base == -1: main_pricelist = obj_list.price_version_id.pricelist_id.id other_pricelist = obj_list.base_pricelist_id.id if main_pricelist == other_pricelist: return False return True |
for line in vals['line_ids']: seq += 1 line[2]['sequence'] = seq vals[seq - 1] = line | if 'line_ids' in vals: for line in vals['line_ids']: seq += 1 line[2]['sequence'] = seq vals[seq - 1] = line | def create(self, cr, uid, vals, context=None): seq = 0 for line in vals['line_ids']: seq += 1 line[2]['sequence'] = seq vals[seq - 1] = line return super(account_bank_statement, self).create(cr, uid, vals, context=context) |
vals = alarm.import_cal(cr, uid, cal_data) | ctx = context.copy() if cal_children: ctx.update({'model': cal_children[cal_data.name.lower()]}) vals = alarm.import_cal(cr, uid, cal_data, context=ctx) | def parse_ics(self, cr, uid, child, cal_children=None, context=None): att_data = [] for cal_data in child.getChildren(): if cal_data.name.lower() == 'attendee': ctx = context.copy() if cal_children: ctx.update({'model': cal_children[cal_data.name.lower()]}) attendee = self.pool.get('basic.calendar.attendee') att_data.append(attendee.import_cal(cr, uid, cal_data, context=ctx)) self.ical_set(cal_data.name.lower(), att_data, 'value') continue if cal_data.name.lower() == 'valarm': alarm = self.pool.get('basic.calendar.alarm') vals = alarm.import_cal(cr, uid, cal_data) self.ical_set(cal_data.name.lower(), vals, 'value') continue if cal_data.name.lower() in self.__attribute__: self.ical_set(cal_data.name.lower(), cal_data.value, 'value') vals = map_data(cr, uid, self) return vals |
data[map_field][0], vevent, context=context) | data[map_field][0], vevent, context=ctx) | def create_ics(self, cr, uid, datas, name, ical, context=None): if not datas: return for data in datas: vevent = ical.add(name) for field in self.__attribute__.keys(): map_field = self.ical_get(field, 'field') map_type = self.ical_get(field, 'type') if map_field in data.keys(): if field == 'uid': model = context.get('model', None) if not model: continue uidval = openobjectid2uid(cr, data[map_field], model) model_obj = self.pool.get(model) r_ids = [] if model_obj._columns.get('recurrent_uid', None): cr.execute('select id from %s where recurrent_uid=%s' % (model_obj._table, data[map_field])) r_ids = map(lambda x: x[0], cr.fetchall()) if r_ids: rdata = self.pool.get(model).read(cr, uid, r_ids) rcal = self.export_cal(cr, uid, rdata, context=context) for revents in rcal.contents['vevent']: ical.contents['vevent'].append(revents) if data.get('recurrent_uid', None): uidval = openobjectid2uid(cr, data['recurrent_uid'], model) vevent.add('uid').value = uidval elif field == 'attendee' and data[map_field]: model = self.__attribute__[field].get('object', False) attendee_obj = self.pool.get('basic.calendar.attendee') vevent = attendee_obj.export_cal(cr, uid, model, \ data[map_field], vevent, context=context) elif field == 'valarm' and data[map_field]: model = self.__attribute__[field].get('object', False) alarm_obj = self.pool.get('basic.calendar.alarm') vevent = alarm_obj.export_cal(cr, uid, model, \ data[map_field][0], vevent, context=context) elif data[map_field]: if map_type in ("char", "text"): vevent.add(field).value = tools.ustr(data[map_field]) elif map_type in ('datetime', 'date') and data[map_field]: if field in ('exdate'): vevent.add(field).value = [parser.parse(data[map_field])] else: vevent.add(field).value = parser.parse(data[map_field]) elif map_type == "timedelta": vevent.add(field).value = timedelta(hours=data[map_field]) elif map_type == "many2one": vevent.add(field).value = tools.ustr(data.get(map_field)[1]) elif map_type in ("float", "integer"): vevent.add(field).value = str(data.get(map_field)) elif map_type == "selection": if not self.ical_get(field, 'mapping'): vevent.add(field).value = (tools.ustr(data[map_field])).upper() else: for key1, val1 in self.ical_get(field, 'mapping').items(): if val1 == data[map_field]: vevent.add(field).value = key1 return vevent |
valarm.add('DESCRIPTION').value = alarm_data['name'] | valarm.add('DESCRIPTION').value = alarm_data['name'] or 'OpenERP' | def export_cal(self, cr, uid, model, alarm_id, vevent, context={}): valarm = vevent.add('valarm') alarm_object = self.pool.get(model) alarm_data = alarm_object.read(cr, uid, alarm_id, []) |
def import_cal(self, cr, uid, ical_data): | def import_cal(self, cr, uid, ical_data, context=None): ctx = context.copy() ctx.update({'model': context.get('model', None)}) self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx) | def import_cal(self, cr, uid, ical_data): for child in ical_data.getChildren(): if child.name.lower() == 'trigger': seconds = child.value.seconds days = child.value.days diff = (days * 86400) + seconds interval = 'days' related = 'before' if not seconds: duration = abs(days) related = days > 0 and 'after' or 'before' elif (abs(diff) / 3600) == 0: duration = abs(diff / 60) interval = 'minutes' related = days >= 0 and 'after' or 'before' else: duration = abs(diff / 3600) interval = 'hours' related = days >= 0 and 'after' or 'before' self.ical_set('trigger_interval', interval, 'value') self.ical_set('trigger_duration', duration, 'value') self.ical_set('trigger_occurs', related.lower(), 'value') if child.params: if child.params.get('related'): self.ical_set('trigger_related', child.params.get('related')[0].lower(), 'value') else: self.ical_set(child.name.lower(), child.value.lower(), 'value') vals = map_data(cr, uid, self) return vals |
ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context) | ids = self.search(cr, user, [('default_code',operator,name)]+ args, limit=limit, context=context) | def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=100): if not args: args=[] if not context: context={} if name: ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context) if not len(ids): ids = self.search(cr, user, [('ean13','=',name)]+ args, limit=limit, context=context) if not len(ids): ids = self.search(cr, user, [('default_code',operator,name)]+ args, limit=limit, context=context) ids += self.search(cr, user, [('name',operator,name)]+ args, limit=limit, context=context) if not len(ids): ptrn=re.compile('(\[(.*?)\])') res = ptrn.search(str(name)) if res: ids = self.search(cr, user, [('default_code','ilike',res.group(2))]+ args, limit=limit, context=context) else: ids = self.search(cr, user, args, limit=limit, context=context) result = self.name_get(cr, user, ids, context) return result |
partner_id = lines[0].partner_id.id if context and context.get('stop_reconcile', False): | partner_id = lines[0].partner_id and lines[0].partner_id.id or False if partner_id and context and context.get('stop_reconcile', False): | def reconcile(self, cr, uid, ids, type='auto', writeoff_acc_id=False, writeoff_period_id=False, writeoff_journal_id=False, context=None): lines = self.browse(cr, uid, ids, context=context) unrec_lines = filter(lambda x: not x['reconcile_id'], lines) credit = debit = 0.0 currency = 0.0 account_id = False partner_id = False if context is None: context = {} |
price = line_obj.price_by_product_OLD(cr, uid, [], | price = line_obj.price_by_product(cr, uid, [], | def add_product(self, cr, uid, order_id, product_id, qty, context=None): |
price = self.price_by_product_OLD(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) | price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) | def _get_amount(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): price = self.price_by_product_OLD(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) res[line.id]=price return res |
price = self.price_by_product_OLD(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) | price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) | def _amount_line_ttc(self, cr, uid, ids, field_name, arg, context): res = dict.fromkeys(ids, 0.0) account_tax_obj = self.pool.get('account.tax') for line in self.browse(cr, uid, ids): tax_amount = 0.0 taxes = [t for t in line.product_id.taxes_id] if line.qty == 0.0: continue computed_taxes = account_tax_obj.compute_all(cr, uid, taxes, line.price_unit, line.qty)['taxes'] for tax in computed_taxes: tax_amount += tax['amount'] price = self.price_by_product_OLD(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) if line.discount!=0.0: res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0) else: res[line.id]=line.price_unit*line.qty res[line.id] = res[line.id] + tax_amount return res |
prices = self.price_by_product_NEW(cr, uid, ids) | def _amount_line(self, cr, uid, ids, field_name, arg, context): res = {} |
|
price = prices[line.id] | price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id) | def _amount_line(self, cr, uid, ids, field_name, arg, context): res = {} |
def price_by_product_NEW(self, cr, uid, ids, context=None): if context is None: context = {} res = {}.fromkeys(ids, 0.0) return res for line in self.browse(cr, uid, ids): pricelist = line.order_id.pricelist_id.id product_id = line.product_id qty = line.qty or 0 partner_id = line.order_id.partner_id.id or False if not product_id: res[line.id] = 0.0 continue if not pricelist: raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist in the sale form !\n' \ 'Please set one before choosing a product.')) uom_id = product_id.uom_po_id.id price = self.pool.get('product.pricelist').price_get(cr, uid, [pricelist], product_id.id, qty or 1.0, partner_id, {'uom': uom_id})[pricelist] unit_price = price or product_id.list_price res[line.id] = unit_price if unit_price is False: raise osv.except_osv(_('No valid pricelist line found !'), _("Couldn't find a pricelist line matching this product" \ " and quantity.\nYou have to change either the product," \ " the quantity or the pricelist.")) return res def price_by_product_OLD(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False): | def price_by_product(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False): | def price_by_product_NEW(self, cr, uid, ids, context=None): if context is None: context = {} |
price = self.price_by_product_OLD(cr, uid, ids, pricelist, product_id, qty, partner_id) | price = self.price_by_product(cr, uid, ids, pricelist, product_id, qty, partner_id) | def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False): price = self.price_by_product_OLD(cr, uid, ids, pricelist, product_id, qty, partner_id) self.write(cr,uid,ids,{'price_unit':price}) pos_stot = (price * qty) return {'value': {'price_unit': price,'price_subtotal_incl': pos_stot}} |
price_f = self.price_by_product_OLD(cr, uid, ids, pricelist, product_id, qty, partner_id) | price_f = self.price_by_product(cr, uid, ids, pricelist, product_id, qty, partner_id) | def onchange_subtotal(self, cr, uid, ids, discount, price, pricelist,qty,partner_id, product_id,*a): prod_obj = self.pool.get('product.product') price_f = self.price_by_product_OLD(cr, uid, ids, pricelist, product_id, qty, partner_id) prod_id='' if product_id: prod_id=prod_obj.browse(cr,uid,product_id).disc_controle disc=0.0 if (disc != 0.0 or prod_id) and price_f>0: disc=100-(price/price_f*100) return {'value':{'discount':disc, 'price_unit':price_f}} return {} |
price = self.price_by_product_OLD(cr, uid, 0, pricelist_id[0]['pricelist_id'][0], product_id[0], 1) | price = self.price_by_product(cr, uid, 0, pricelist_id[0]['pricelist_id'][0], product_id[0], 1) | def _scan_product(self, cr, uid, ean, qty, order): # search pricelist_id product_obj=self.pool.get('product.product') pricelist_id = self.pool.get('pos.order').read(cr, uid, [order], ['pricelist_id'] ) if not pricelist_id: return False |
res.append(dct) | res.append((0,0,dct)) | def _get_cash_box_lines(self, cr, uid, ids, context={}): res = [] curr = [1, 2, 5, 10, 20, 50, 100, 500] for rs in curr: dct = { 'pieces':rs, 'number':0 } res.append(dct) return res |
account_id = operation.product_id.property_account_income | account_id = operation.product_id.property_account_income.id | def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } inv_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id}) |
if preinv.state not in ('cancel',): | if preinv.state not in ('cancel',) and preinv.id not in from_line_invoice_ids: | def _make_invoice(self, cr, uid, order, lines, context=None): journal_obj = self.pool.get('account.journal') inv_obj = self.pool.get('account.invoice') |
account_id = fee.product_id.property_account_income | account_id = fee.product_id.property_account_income.id | def action_invoice_create(self, cr, uid, ids, group=False, context=None): """ Creates invoice(s) for repair order. @param group: It is set to true when group invoice is to be generated. @return: Invoice Ids. """ res = {} invoices_group = {} inv_line_obj = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') repair_line_obj = self.pool.get('mrp.repair.line') repair_fee_obj = self.pool.get('mrp.repair.fee') for repair in self.browse(cr, uid, ids, context=context): res[repair.id] = False if repair.state in ('draft','cancel') or repair.invoice_id: continue if not (repair.partner_id.id and repair.partner_invoice_id.id): raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !')) comment = repair.quotation_notes if (repair.invoice_method != 'none'): if group and repair.partner_invoice_id.id in invoices_group: inv_id = invoices_group[repair.partner_invoice_id.id] invoice = inv_obj.browse(cr, uid, inv_id) invoice_vals = { 'name': invoice.name +', '+repair.name, 'origin': invoice.origin+', '+repair.name, 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''), } inv_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: if not repair.partner_id.property_account_receivable: raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, 'comment': repair.quotation_notes, 'fiscal_position': repair.partner_id.property_account_position.id } inv_id = inv_obj.create(cr, uid, inv) invoices_group[repair.partner_invoice_id.id] = inv_id self.write(cr, uid, repair.id, {'invoiced': True, 'invoice_id': inv_id}) |
datas['id'] = caldav_id2real_id(datas['id']) super(virtual_report_spool, self).exp_report(db, uid, object, new_ids, datas, context) | datas['id'] = caldav_id2real_id(datas['id']) | def exp_report(self, db, uid, object, ids, datas=None, context=None): if object == 'printscreen.list': return super(virtual_report_spool, self).exp_report(db, uid, \ object, ids, datas, context) new_ids = [] for id in ids: new_ids.append(caldav_id2real_id(id)) datas['id'] = caldav_id2real_id(datas['id']) super(virtual_report_spool, self).exp_report(db, uid, object, new_ids, datas, context) return super(virtual_report_spool, self).exp_report(db, uid, object, new_ids, datas, context) |
'partner_account': fields.boolean('Partner account'), | def _check_percent(self, cr, uid, ids, context={}): obj = self.browse(cr, uid, ids[0]) if obj.value == 'procent' and ( obj.value_amount < 0.0 or obj.value_amount > 1.0): return False return True |
|
('view', 'View'), | def _get_level(self, cr, uid, ids, field_name, arg, context={}): res={} accounts = self.browse(cr, uid, ids) for account in accounts: level = 0 if account.parent_id : obj = self.browse(cr, uid, account.parent_id.id) level = obj.level + 1 res[account.id] = level return res |
|
('other', 'Others'), | def _get_level(self, cr, uid, ids, field_name, arg, context={}): res={} accounts = self.browse(cr, uid, ids) for account in accounts: level = 0 if account.parent_id : obj = self.browse(cr, uid, account.parent_id.id) level = obj.level + 1 res[account.id] = level return res |
|
(tmpl_id, product_id, pricelist_id, qty)) | (tmpl_id, product_id, plversion_ids[0], qty)) | def _create_parent_category_list(id, lst): if not id: return [] parent = product_category_tree.get(id) if parent: lst.append(parent) return _create_parent_category_list(parent, lst) else: return lst |
vals = map_data(cr, uid, self) if vals: res.append(vals) self.ical_reset('value') | if child.name.lower() in ('vevent', 'vtodo'): vals = map_data(cr, uid, self) else: vals = {} continue if vals: res.append(vals) self.ical_reset('value') | def import_ical(self, cr, uid, ical_data): parsedCal = vobject.readOne(ical_data) att_data = [] res = [] for child in parsedCal.getChildren(): for cal_data in child.getChildren(): if cal_data.name.lower() == 'attendee': attendee = self.pool.get('caldav.attendee') att_data.append(attendee.import_ical(cr, uid, cal_data)) self.ical_set(cal_data.name.lower(), att_data, 'value') continue if cal_data.name.lower() == 'valarm': alarm = self.pool.get('caldav.alarm') vals = alarm.import_ical(cr, uid, cal_data) self.ical_set(cal_data.name.lower(), vals, 'value') continue if cal_data.name.lower() in self.__attribute__: self.ical_set(cal_data.name.lower(), cal_data.value, 'value') vals = map_data(cr, uid, self) if vals: res.append(vals) self.ical_reset('value') return res |
'invoice_ids': fields.many2many('account.invoice', 'purchase_invoice_rel', 'purchase_id', 'invoice_id', 'Taxes', help="Invoices generated for a purchase order"), | 'invoice_ids': fields.many2many('account.invoice', 'purchase_invoice_rel', 'purchase_id', 'invoice_id', 'Invoices', help="Invoices generated for a purchase order"), | def _invoiced(self, cursor, user, ids, name, arg, context=None): res = {} for purchase in self.browse(cursor, user, ids, context=context): invoiced = False if purchase.invoiced_rate == 100.00: invoiced = True res[purchase.id] = invoiced return res |
where += safe_eval(self.domain, self.dctx) | app = safe_eval(self.domain, self.dctx) if not app: pass elif isinstance(app, list): where.extend(app) elif isinstance(app, tuple): where.append(app) else: raise RuntimeError("incorrect domain expr: %s" % self.domain) | def _child_get(self, cr, name = None, domain=None): """ return virtual children of resource, based on the foreign object. Note that many objects use NULL for a name, so we should better call the name_search(),name_get() set of methods """ obj = self.context._dirobj.pool.get(self.res_model) if not obj: return [] dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [] if self.domain: where += safe_eval(self.domain, self.dctx) if self.resm_id: where.append(('id','=',self.resm_id)) if name: where.append((self.namefield,'=',name)) # print "Where clause for %s" % self.res_model, where if self.ressource_tree: object2 = False if self.resm_id: object2 = dirobj.pool.get(self.res_model).browse(cr, uid, self.resm_id) or False if obj._parent_name in obj.fields_get(cr, uid): where.append((obj._parent_name,'=',object2 and object2.id or False)) resids = obj.search(cr, uid, where, context=ctx) res = [] for bo in obj.browse(cr, uid, resids, context=ctx): if not bo: continue name = getattr(bo, self.namefield) if not name: continue # Yes! we can't do better but skip nameless records. res.append(node_res_obj(name, self.dir_id, self, self.context, self.res_model, bo)) return res |
case = pool.get('crm.lead').browse(cr, uid, data['id']) | case = pool.get(data.get('model')).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.lead').browse(cr, uid, data['id']) 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 False | return (False, None) | def uid2openobjectid(cr, uidval, oomodel, rdate): __rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$') wematch = __rege.match(uidval.encode('utf8')) if not wematch: return (False, None) else: model, id, dbname = wematch.groups() model_obj = pooler.get_pool(cr.dbname).get(model) if (not model == oomodel) or (not dbname == cr.dbname): return (False, None) qry = 'select distinct(id) from %s' % model_obj._table if rdate: qry += " where recurrent_id='%s'" % (rdate) cr.execute(qry) r_id = cr.fetchone() if r_id: return (id, r_id[0]) cr.execute(qry) ids = map(lambda x: str(x[0]), cr.fetchall()) if id in ids: return (id, None) return False |
'active': fields.boolean('Active'), | 'active': fields.boolean('Active'), 'create_date': fields.datetime('Created Date'), 'write_date': fields.datetime('Modifided Date'), | def import_cal(self, cr, uid, content, data_id=None, context=None): ical_data = base64.decodestring(content) self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, context) parsedCal = vobject.readOne(ical_data) att_data = [] res = [] for child in parsedCal.getChildren(): if child.name.lower() in ('vevent', 'vtodo'): vals = self.parse_ics(cr, uid, child, context=context) else: vals = {} continue if vals: res.append(vals) self.ical_reset('value') return res |
def export_cal(self, cr, uid, datas, vobj='vevent', context={}): cal = self.browse(cr, uid, datas[0]) ical = vobject.iCalendar() | def export_cal(self, cr, uid, ids, vobj='vevent', context={}): cal = self.browse(cr, uid, ids[0]) ical = vobject.iCalendar() | def export_cal(self, cr, uid, datas, vobj='vevent', context={}): cal = self.browse(cr, uid, datas[0]) ical = vobject.iCalendar() for line in cal.line_ids: if line.name in ('valarm', 'attendee'): continue mod_obj = self.pool.get(line.object_id.model) data_ids = mod_obj.search(cr, uid, eval(line.domain), context=context) datas = mod_obj.read(cr, uid, data_ids, context=context) context.update({'model': line.object_id.model}) self.__attribute__ = get_attribute_mapping(cr, uid, line.name, context) self.create_ics(cr, uid, datas, line.name, ical, context=context) return ical.serialize() |
raise osv.except_osv(_('Configuration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) | raise osv.except_osv(_('Configuration Error !'), _('Can\'t find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Financial Accounting\Accounts\Journals.' % (journal_type))) | def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') 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: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.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 = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.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 pay_res_id: raise osv.except_osv(_('Configuration 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} account_obj = self.pool.get('account.account') 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 = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configuration 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 = account_obj.browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configuration Error !'), _('invoice line account company is not match with invoice company.')) else: continue 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(_('Configuration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, []) |
if currency.company_id.id != company_id: | if currency.company_id and currency.company_id.id != company_id: | def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') 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: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.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 = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.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 pay_res_id: raise osv.except_osv(_('Configuration 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} account_obj = self.pool.get('account.account') 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 = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configuration 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 = account_obj.browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configuration Error !'), _('invoice line account company is not match with invoice company.')) else: continue 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(_('Configuration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, []) |
if company.currency_id.company_id.id != company_id: | if company.currency_id.company_id and company.currency_id.company_id.id != company_id: | def onchange_company_id(self, cr, uid, ids, company_id, part_id, type, invoice_line, currency_id): val = {} dom = {} obj_journal = self.pool.get('account.journal') 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: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.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 = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value','res_id']) pay_line_data = property_obj.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 pay_res_id: raise osv.except_osv(_('Configuration 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} account_obj = self.pool.get('account.account') 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 = account_obj.search(cr, uid, [('name','=',line.account_id.name),('company_id','=',company_id)]) if not result_id: raise osv.except_osv(_('Configuration 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 = account_obj.browse(cr, uid, inv_line[2]['account_id']) if obj_l.company_id.id != company_id: raise osv.except_osv(_('Configuration Error !'), _('invoice line account company is not match with invoice company.')) else: continue 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(_('Configuration Error !'), _('Can not find account journal for this company in invoice, Please Create journal.')) dom = {'journal_id': [('id', 'in', journal_ids)]} else: journal_ids = obj_journal.search(cr, uid, []) |
if not currency.company_id.id == company.id: raise osv.except_osv(_('Configuration Error !'), _('Can not select currency that is not related to any company.\nPlease select accordingly !.')) | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id) or False |
|
'name':'Salary Slip of %s for %s' % (slip.employee_id.name, ttyme.strftime('%B-%Y')), | 'name':'Salary Slip of %s for %s' % (slip.employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))), | def get_days(start, end, month, year, calc_day): import datetime count = 0 for day in range(start, end): if datetime.date(year, month, day).weekday() == calc_day: count += 1 return count |
default['name'] = self.browse(cr, uid, id, context=context).name + _(' (copy)') | default['name'] = self.browse(cr, uid, id, context=context).name | def copy_data(self, cr, uid, id, default={}, context=None): default = default or {} default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False}) if not default.get('remaining_hours', False): default['remaining_hours'] = float(self.read(cr, uid, id, ['planned_hours'])['planned_hours']) default['active'] = True default['type_id'] = False if not default.get('name', False): default['name'] = self.browse(cr, uid, id, context=context).name + _(' (copy)') return super(task, self).copy_data(cr, uid, id, default, context) |
return True | return res | def case_reset(self, cr, uid, ids, *args): """Overrides reset as draft in order to set the stage field as empty @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of case Ids @param *args: Tuple Value for additional Params """ res = super(crm_opportunity, self).case_reset(cr, uid, ids, *args) self.write(cr, uid, ids, {'stage_id': False}) return True |
return self.baseuri+ '/'.join(ajoin) | return self.parent.get_baseuri(self) + '/'.join(ajoin) | def urijoin(self,*ajoin): """ Return the base URI of this request, or even join it with the ajoin path elements """ return self.baseuri+ '/'.join(ajoin) |
"From Picking: a draft invoice will be pre-generated based on validated receptions.\n" \ | "From Picking: you manually have to generate the invoices based on the receptions.\n" \ | def _invoiced(self, cursor, user, ids, name, arg, context=None): res = {} for purchase in self.browse(cursor, user, ids, context=context): if purchase.invoice_id.reconciled: res[purchase.id] = purchase.invoice_id.reconciled else: res[purchase.id] = False return res |
res.update({'reply_to': case.section_id and case.section_id.reply_to or False}) | if hasattr(case, 'section_id'): res.update({'reply_to': case.section_id and case.section_id.reply_to or False}) | def default_get(self, cr, uid, fields, context=None): """ This function gets default values """ if not context: context = {} |
res.update({'reply_to': case.section_id.reply_to}) | if hasattr(case, 'section_id'): res.update({'reply_to': case.section_id.reply_to}) | def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('mailgate.message') res_ids = context and context.get('active_ids', []) or [] |
if not context.get('journal_id', False) and context.get('search_default_journal_id', False): context['journal_id'] = context.get('search_default_journal_id') | def _default_get(self, cr, uid, fields, context={}): |
|
if mv.partner_id: line['partner_id'] = mv.partner_id.id if line['amount'] < 0 : line['account_id'] = mv.partner_id.property_account_payable.id else : line['account_id'] = mv.partner_id.property_account_receivable.id | mv = pool.get('account.move.line').browse(cr, uid, rec_id[0], context=context) if mv.partner_id: line['partner_id'] = mv.partner_id.id if line['amount'] < 0 : line['account_id'] = mv.partner_id.property_account_payable.id else : line['account_id'] = mv.partner_id.property_account_receivable.id | def coda_parsing(self, cr, uid, ids, context=None): |
def _default_get(self, cr, uid, fields, context={}): | def convert_to_period(self, cr, uid, context={}): | def _default_get(self, cr, uid, fields, context={}): period_obj = self.pool.get('account.period') |
ref = {} | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] if not model == 'calendar.attendee': ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.append({'email': datas['email']}) mail_to.append(datas['email']) |
|
vals.append({'email': datas['email']}) | res = {'email': datas['email']} res.update(ref) vals.append(res) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] if not model == 'calendar.attendee': ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.append({'email': datas['email']}) mail_to.append(datas['email']) |
if model == 'calendar.attendee': att = att_obj.browse(cr, uid, context['active_id']) vals.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref }) | att = att_obj.browse(cr, uid, context['active_id']) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] if not model == 'calendar.attendee': ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.append({'email': datas['email']}) mail_to.append(datas['email']) |
attendees.append(int(att_obj.create(cr, uid, att_val, context=context))) | if model == 'calendar.attendee': att_val.update({ 'parent_ids' : [(4, att.id)], 'ref': att.ref._name + ',' + str(att.ref.id) }) attendees.append(att_obj.create(cr, uid, att_val)) | def do_invite(self, cr, uid, ids, context={}): for att_id in ids: datas = self.read(cr, uid, att_id) model = False model_field = False if not context or not context.get('model'): return {} else: model = context.get('model') model_field = context.get('attendee_field', False) obj = self.pool.get(model) res_obj = obj.browse(cr, uid, context['active_id']) type = datas.get('type') att_obj = self.pool.get('calendar.attendee') vals = [] mail_to = [] attendees = [] if not model == 'calendar.attendee': ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))} if type == 'internal': user_obj = self.pool.get('res.users') if not datas.get('user_ids'): raise osv.except_osv(_('Error!'), ("Please select any User")) for user_id in datas.get('user_ids'): user = user_obj.browse(cr, uid, user_id) res = { 'user_id': user_id, 'email': user.address_id.email } res.update(ref) vals.append(res) if user.address_id.email: mail_to.append(user.address_id.email) elif type == 'external' and datas.get('email'): vals.append({'email': datas['email']}) mail_to.append(datas['email']) |
event_ref = ref if event_ref.user_id.id != user[0]: | if ref.user_id.id != user[0]: | def do_accept(self, cr, uid, ids, context=None, *args): for invite in ids: vals = self.read(cr, uid, invite, context=context) user = vals.get('user_id') if user: ref = vals.get('ref', None) if ref: event_ref = ref if event_ref.user_id.id != user[0]: defaults = {'user_id': user[0]} new_event = model_obj.copy(cr, uid, event, default=defaults, context=context) self.write(cr, uid, invite, {'state': 'accepted'}, context) return True |
def create(self, cr, uid, vals, context={}): | def create(self, cr, uid, vals, context=None): if not context: context = {} | def create(self, cr, uid, vals, context={}): if not vals.get("email") and vals.get("cn"): cnval = vals.get("cn").split(':') email = filter(lambda x:x.__contains__('@'), cnval) vals['email'] = email[0] vals['cn'] = vals.get("cn") res = super(calendar_attendee, self).create(cr, uid, vals, context) return res |
def get_id(self, cr, uid, sequence_id, test='id=%s', context={}): cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) | def get_id(self, cr, uid, sequence_id, test='id', context={}): cr.execute('select id from ir_sequence where '+test+'=%s and active=%s', (sequence_id, True,)) | def get_id(self, cr, uid, sequence_id, test='id=%s', context={}): cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) res = cr.dictfetchone() if res: for line in self.browse(cr, uid, res['id'], context=context).fiscal_ids: if line.fiscalyear_id.id==context.get('fiscalyear_id', False): return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id=%s", context=context) return super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context) |
return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id=%s", context=context) | return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id", context=context) | def get_id(self, cr, uid, sequence_id, test='id=%s', context={}): cr.execute('select id from ir_sequence where '+test+' and active=%s', (sequence_id, True,)) res = cr.dictfetchone() if res: for line in self.browse(cr, uid, res['id'], context=context).fiscal_ids: if line.fiscalyear_id.id==context.get('fiscalyear_id', False): return super(ir_sequence, self).get_id(cr, uid, line.sequence_id.id, test="id=%s", context=context) return super(ir_sequence, self).get_id(cr, uid, sequence_id, test, context) |
'create_date': fields.datetime('Date Created', readonly=True), | def init(self, cr): tools.drop_view_if_exists(cr, 'report_document_user') cr.execute(""" CREATE OR REPLACE VIEW report_document_user as ( SELECT min(f.id) as id, to_char(f.create_date, 'YYYY') as name, to_char(f.create_date, 'MM') as month, f.user_id as user_id, u.name as user, count(*) as nbr, d.name as directory, f.create_date as create_date, f.file_size as file_size, min(d.type) as type, f.write_date as change_date FROM ir_attachment f left join document_directory d on (f.parent_id=d.id and d.name<>'') inner join res_users u on (f.user_id=u.id) group by to_char(f.create_date, 'YYYY'), to_char(f.create_date, 'MM'),d.name,f.parent_id,d.type,f.create_date,f.user_id,f.file_size,u.name,d.type,f.write_date ) """) |
|
cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) | cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN (%s))" %(dept_ids_set,)) | def calculate_sales_history(self, cr, uid, ids, context, *args): sales=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],] for obj in self.browse(cr, uid, ids): periods =obj.analyzed_period1_id, obj.analyzed_period2_id, obj.analyzed_period3_id, obj.analyzed_period4_id, obj.analyzed_period5_id so_obj = self.pool.get('sale.order') so_line_obj= self.pool.get('sale.order.line') so_line_product_ids = so_line_obj.search(cr, uid, [('product_id','=', obj.product_id.id)], context = context) if so_line_product_ids: so_line_product_set = ','.join(map(str,so_line_product_ids)) if obj.analyzed_warehouse_id: shops = self.pool.get('sale.shop').search(cr, uid,[('warehouse_id','=', obj.analyzed_warehouse_id.id)], context = context) shops_set = ','.join(map(str,shops)) else: shops = False if obj.analyzed_dept_id: dept_obj = self.pool.get('hr.department') dept_id = obj.analyzed_dept_id.id and [obj.analyzed_dept_id.id] or [] dept_ids = dept_obj.search(cr,uid,[('parent_id','child_of',dept_id)]) dept_ids_set = ','.join(map(str,dept_ids)) cr.execute("SELECT user_id FROM hr_department_user_rel WHERE (department_id IN %s)" %(tuple(dept_ids_set),)) dept_users = [x for x, in cr.fetchall()] dept_users_set = ','.join(map(str,dept_users)) else: dept_users = False factor, round_value = self._from_default_uom_factor(cr, uid, obj, obj.product_uom.id, context=context) for i, period in enumerate(periods): if period: so_period_ids = so_obj.search(cr, uid, [('date_order','>=',period.date_start), ('date_order','<=',period.date_stop)], context = context) if so_period_ids: so_period_set = ','.join(map(str,so_period_ids)) if obj.analyzed_user_id: user_set = str(obj.analyzed_user_id.id) sales[i][0] =self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, user_set) sales[i][0] *=factor if dept_users: sales[i][1]= self._sales_per_users(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, dept_users_set) sales[i][1]*=factor if shops: sales[i][2]= self._sales_per_warehouse(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, shops_set) sales[i][2]*=factor if obj.analyze_company: sales[i][3]= self._sales_per_company(cr, uid, so_period_set, so_line_product_set, obj.company_id.id, ) sales[i][3]*=factor self.write(cr, uid, ids, { 'analyzed_period1_per_user':sales[0][0], 'analyzed_period2_per_user':sales[1][0], 'analyzed_period3_per_user':sales[2][0], 'analyzed_period4_per_user':sales[3][0], 'analyzed_period5_per_user':sales[4][0], 'analyzed_period1_per_dept':sales[0][1], 'analyzed_period2_per_dept':sales[1][1], 'analyzed_period3_per_dept':sales[2][1], 'analyzed_period4_per_dept':sales[3][1], 'analyzed_period5_per_dept':sales[4][1], 'analyzed_period1_per_warehouse':sales[0][2], 'analyzed_period2_per_warehouse':sales[1][2], 'analyzed_period3_per_warehouse':sales[2][2], 'analyzed_period4_per_warehouse':sales[3][2], 'analyzed_period5_per_warehouse':sales[4][2], 'analyzed_period1_per_company':sales[0][3], 'analyzed_period2_per_company':sales[1][3], 'analyzed_period3_per_company':sales[2][3], 'analyzed_period4_per_company':sales[3][3], 'analyzed_period5_per_company':sales[4][3], }) return True |
for id in context['active_ids']: | pool_obj = pooler.get_pool(cr.dbname) data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) for record in data_inv: if record['state'] not in ('draft','proforma','proforma2'): raise osv.except_osv(_('Warning'), _("Selected Invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state!")) | def invoice_confirm(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService('workflow') if context is None: context = {} for id in context['active_ids']: wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr) return {} |
_description = "Cancel the selected invoices" | _description = "Cancel the Selected Invoices" | def invoice_confirm(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService('workflow') if context is None: context = {} for id in context['active_ids']: wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_open', cr) return {} |
wf_service = netsvc.LocalService('workflow') | def invoice_cancel(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService('workflow') if context is None: context = {} for id in context['active_ids']: wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr) return {} |
|
for id in context['active_ids']: wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr) | wf_service = netsvc.LocalService('workflow') pool_obj = pooler.get_pool(cr.dbname) data_inv = pool_obj.get('account.invoice').read(cr, uid, context['active_ids'], ['state'], context=context) for record in data_inv: if record['state'] in ('cancel','paid'): raise osv.except_osv(_('Warning'), _("Selected Invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state!")) wf_service.trg_validate(uid, 'account.invoice', record['id'], 'invoice_cancel', cr) | def invoice_cancel(self, cr, uid, ids, context=None): wf_service = netsvc.LocalService('workflow') if context is None: context = {} for id in context['active_ids']: wf_service.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr) return {} |
if len(ids) > 0: | if len(ids) > 1: | def _check_queue(self, cr, uid, ids=False): queue = self.pool.get('email.smtpclient.queue') sids = [] if not ids: sids = queue.search(cr, uid, [('state','not in',['send','sending']), ('type','=','system')], order="priority", limit=30) ids =[] else: sids = queue.search(cr, uid, [('state','not in',['send','sending']), ('server_id','in',ids)], order="priority", limit=30) message = "" if len(ids) > 0: message = "sending %s emails from message queuq !" % (len(ids)) logger.notifyChannel('smtp', netsvc.LOG_INFO, message) result = self. _send_emails(cr, uid, sids, {}) return result |
account_sum += l['debit'] - l['credit'] | account_sum += l['credit']-l['debit'] | def lines(self, period_id, journal_id=False): if not journal_id: journal_id = self.journal_ids else: journal_id = [journal_id] obj_mline = self.pool.get('account.move.line') self.cr.execute('update account_journal_period set state=%s where journal_id IN %s and period_id=%s and state=%s', ('printed', self.journal_ids, period_id, 'draft')) |
class VoucherLine(osv.osv): | class account_voucher_line(osv.osv): | def action_move_line_create(self, cr, uid, ids, *args): for inv in self.browse(cr, uid, ids): if inv.move_id: continue company_currency = inv.company_id.currency_id.id |
data = super(VoucherLine, self).default_get(cr, uid, fields, context) | data = super(account_voucher_line, self).default_get(cr, uid, fields, context) | def default_get(self, cr, uid, fields, context={}): data = super(VoucherLine, self).default_get(cr, uid, fields, context) self.voucher_context = context return data |
res = super(VoucherLine, self).move_line_get_item(cr, uid, line, context) | res = super(account_voucher_line, self).move_line_get_item(cr, uid, line, context) | def move_line_get_item(self, cr, uid, line, context={}): res = super(VoucherLine, self).move_line_get_item(cr, uid, line, context) res['invoice'] = line.invoice_id or False return res |
VoucherLine() | account_voucher_line() | def onchange_line_account(self, cr, uid, ids, account_id, type, type1): if not account_id: return {'value' : {'account_id' : False, 'type' : False ,'amount':False}} obj = self.pool.get('account.account') acc_id = False if type1 in ('rec_voucher','bank_rec_voucher', 'journal_voucher'): acc_id = obj.browse(cr, uid, account_id) balance = acc_id.credit type = 'cr' elif type1 in ('pay_voucher','bank_pay_voucher','cont_voucher') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.debit type = 'dr' elif type1 in ('journal_sale_vou') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.credit type = 'dr' elif type1 in ('journal_pur_voucher') : acc_id = obj.browse(cr, uid, account_id) balance = acc_id.debit type = 'cr' |
if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): | if vals.get('project_id',False) or vals.get('name',False): | def write(self, cr, uid, ids,vals,context=None): if context is None: context = {} if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): vals_line = {} hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') task_obj_l = self.browse(cr, uid, ids, context) if (vals.has_key('project_id') and vals['project_id']): project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) acc_id = project_obj.analytic_account_id.id |
if (vals.has_key('project_id') and vals['project_id']): | if vals.get('project_id',False): | def write(self, cr, uid, ids,vals,context=None): if context is None: context = {} if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): vals_line = {} hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') task_obj_l = self.browse(cr, uid, ids, context) if (vals.has_key('project_id') and vals['project_id']): project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) acc_id = project_obj.analytic_account_id.id |
line_id = task_work.hr_analytic_timesheet_id if (vals.has_key('project_id') and vals['project_id']): | line_id = task_work.hr_analytic_timesheet_id.id if vals.get('project_id',False): | def write(self, cr, uid, ids,vals,context=None): if context is None: context = {} if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): vals_line = {} hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') task_obj_l = self.browse(cr, uid, ids, context) if (vals.has_key('project_id') and vals['project_id']): project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) acc_id = project_obj.analytic_account_id.id |
if (vals.has_key('name') and vals['name']): | if vals.get('name',False): | def write(self, cr, uid, ids,vals,context=None): if context is None: context = {} if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): vals_line = {} hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') task_obj_l = self.browse(cr, uid, ids, context) if (vals.has_key('project_id') and vals['project_id']): project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) acc_id = project_obj.analytic_account_id.id |
AND (aal.account_id IN aal.account_id IN %s)\ | AND (aal.account_id IN %s)\ | def _lines_g(self, account_id, date1, date2): account_analytic_obj = self.pool.get('account.analytic.account') ids = account_analytic_obj.search(self.cr, self.uid, [('parent_id', 'child_of', [account_id])]) self.cr.execute("SELECT aa.name AS name, aa.code AS code, \ sum(aal.amount) AS balance, sum(aal.unit_amount) AS quantity \ FROM account_analytic_line AS aal, account_account AS aa \ WHERE (aal.general_account_id=aa.id) \ AND (aal.account_id IN aal.account_id IN %s)\ AND (date>=%s) AND (date<=%s) AND aa.active \ GROUP BY aal.general_account_id, aa.name, aa.code, aal.code \ ORDER BY aal.code", (tuple(ids), date1, date2)) res = self.cr.dictfetchall() |
return all(procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids)) | res = True for proc in self.browse(cr, uid, ids, context): if proc.move_id: if not proc.move_id.state=='done': res = False return res | def check_move_done(self, cr, uid, ids, context={}): """ Checks if move is done or not. @return: True or False. """ return all(procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids)) |
('other','Others'), ],'Type', select=True), | ('leaves','Leaves'), ('advance','Advance'), ('loan','Loan'), ('installment','Loan Installment'), ('otherpay','Other Payment'), ('otherdeduct','Other Deduction'), ],'Type', select=True, required=True), | def _total(self, cr, uid, ids, field_names, arg, context=None): if context is None: context = {} res={} for line in self.browse(cr, uid, ids, context=context): res[line.id] = line.emp_deduction + line.comp_deduction return res |
'code':fields.char('Code', size=64, required=False, readonly=False), | 'code': fields.related('head_id','code', type='char', relation='hr.allounce.deduction.categoty', string='Code'), | def compute(self, cr, uid, id, value, context={}): contrib = self.browse(cr, uid, id, context) if contrib.amount_type == 'fix': return contrib.contribute_per elif contrib.amount_type == 'per': return value * contrib.contribute_per elif contrib.amount_type == 'func': return self._execute_function(cr, uid, id, value, context) return 0.0 |
'code':fields.char('Code', size=64, required=False, readonly=False), | 'code':fields.char('Code', size=64, required=False, readonly=False), 'category_id':fields.many2one('hr.allounce.deduction.categoty', 'Category', required=True), | def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}} |
'category_id':fields.many2one('hr.allounce.deduction.categoty', 'Category', required=True), | def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}} |
|
],'Amount Type', select=True), | ],'Amount Type', select=True, required=True), | def onchange_amount(self, cr, uid, ids, amount, typ): amt = amount if typ and typ == 'per': if int(amt) > 0: amt = amt / 100 return {'value':{'amount':amt}} |
if cnt: | if not cnt: | def _result_get(x, keys): if x[1] in keys: return False keys.append(x[1]) if x[3]: model,id = x[2].split(',') id = int(id) fields = self.pool.get(model).fields_get_keys(cr, uid) pos = 0 while pos<len(fields): if fields[pos] in ('report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml', 'report_sxw_content_data', 'report_rml_content_data'): del fields[pos] else: pos+=1 try: datas = self.pool.get(model).read(cr, uid, [id], fields, context) except except_orm, e: return False datas= datas and datas[0] or None if not datas: #ir_del(cr, uid, x[0]) return False else: datas = pickle.loads(str(x[2].encode('utf-8'))) if meta: meta2 = pickle.loads(x[4]) return (x[0],x[1],datas,meta2) return (x[0],x[1],datas) |
res[line.id] = float(line.practical_amount or 0.0 / line.theoritical_amount) * 100 | res[line.id] = float((line.practical_amount or 0.0) / line.theoritical_amount) * 100 | def _perc(self, cr, uid, ids, name, args, context): res = {} for line in self.browse(cr, uid, ids): if line.theoritical_amount <> 0.00: res[line.id] = float(line.practical_amount or 0.0 / line.theoritical_amount) * 100 else: res[line.id] = 0.00 return res |
uom = False, partner_id = sale.partner_id.id, fiscal_position = sale.fiscal_position.id) | uom = False, partner_id = sale.partner_id.id, fposition_id = sale.fiscal_position.id) | def create_invoices(self, cr, uid, ids, context={}): """ To create invoices. |
if data_holiday[0].holiday_status_id.double_validation: | if not data_holiday[0].holiday_status_id.double_validation: | def holidays_validate(self, cr, uid, ids, *args): data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) if data_holiday[0].holiday_status_id.double_validation: vals = {'state':'validate1'} else: vals = {'state':'validate'} ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)]) if ids2: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'),_('No user related to the selected employee.')) self.write(cr, uid, ids, vals) if data_holiday[0].holiday_status_id.double_validation: for record in data_holiday: if record.holiday_type=='employee' and record.type=='remove': vals= { 'name':record.name, 'date_from':record.date_from, 'date_to':record.date_to, 'calendar_id':record.employee_id.calendar_id.id, 'company_id':record.employee_id.company_id.id, 'resource_id':record.employee_id.resource_id.id } self.pool.get('resource.calendar.leaves').create(cr, uid, vals) return True |
cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s", (id,)) | cr.execute("DELETE FROM account_invoice_tax WHERE invoice_id=%s AND manual is False", (id,)) | def button_reset_taxes(self, cr, uid, ids, context=None): if context is None: context = {} ctx = context.copy() 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=ctx).partner_id if partner.lang: ctx.update({'lang': partner.lang}) for taxe in ait_obj.compute(cr, uid, id, context=ctx).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=ctx) return True |
'opp_id': opp.id | 'opportunity_id': opp.id | def action_apply(self, cr, uid, ids, context=None): """ This converts Opportunity to Phonecall and opens Phonecall view @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Opportunity to Phonecall IDs @param context: A standard dictionary for contextual values |
type='many2one', relation='res.country', string='Country'), | type='many2one', relation='res.country',string='Country'), 'total_cost' : fields.function(_total_cost, string='Cost', method=True, type="float", store=True), 'revenue': fields.float('Revenue',readonly=True), | def _total_cost(self, cr, uid, ids, field_name, arg, context={}): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.