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.p...
'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.p...
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.p...
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 h...
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=...
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 = s...
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,...
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_...
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 = ...
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 = ...
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') supp...
'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.a...
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('m...
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' ...
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, l...
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 = Fa...
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...
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 no...
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 di...
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('a...
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('a...
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_...
'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))...
'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...
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 { '...
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 (no...
'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',...
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)...
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...
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...
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...
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.excep...
'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'])...
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 addition...
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.brow...
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.brow...
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.brow...
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.brow...
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, e...
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', Fa...
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', Fa...
'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.c...
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('...
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...
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) canno...
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']), ('...
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, p...
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, acco...
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_k...
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_k...
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_k...
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_k...
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 q...
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, con...
'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_...
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)]) ...
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.lan...
'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 con...
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={}):