rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def action_done(self, cr, uid, ids, context=None):
def action_done(self, cr, uid, ids, context={}):
def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)'...
product_uom_obj = self.pool.get('product.uom')
def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)'...
company_id=move.company_id.id context['currency_id']=move.company_id.currency_id.id pricetype=self.pool.get('product.price.type').browse(cr,uid,move.company_id.property_valuation_price_type.id) amount_unit=move.product_id.price_get(pricetype.field, context)[move.product_id.id] amount=amount_unit * q or 1.0
company_id = move.company_id.id context['currency_id'] = move.company_id.currency_id.id pricetype = price_type_obj.browse(cr,uid,move.company_id.property_valuation_price_type.id) amount_unit = move.product_id.price_get(pricetype.field, context)[move.product_id.id] amount = amount_unit * q or 1.0
def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)'...
self.pool.get('account.move').create(cr, uid, {
move_obj.create(cr, uid, {
def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)'...
tracking_id = context.get('tracking_id', False) if tracking_id: tracking = self.pool.get('stock.tracking') tracking_id = tracking.get_create_tracking_lot(cr, uid,[rec_id], context=context ) self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S'), 'tracking_id': tracking_id}) for p...
tracking_id = False if context: tracking_id = context.get('tracking_id', False) if tracking_id: rec_id = context and context.get('active_id', False) tracking = self.pool.get('stock.tracking') tracking_id = tracking.get_create_tracking_lot(cr, uid,[rec_id], context=context ) self.write(cr, uid, ids, {'state': 'done', '...
def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)'...
self.pool.get('stock.picking').action_done(cr, uid, [pick.id])
picking_obj.action_done(cr, uid, [pick.id])
def action_done(self, cr, uid, ids, context=None): track_flag = False picking_ids = [] for move in self.browse(cr, uid, ids): if move.picking_id: picking_ids.append(move.picking_id.id) if move.move_dest_id.id and (move.state != 'done'): cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)'...
val_invoice = pool_obj.get('account.invoice').onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False)
val_invoice = inv_obj.onchange_partner_id(cr, uid, [], 'out_invoice', reg.partner_invoice_id.id, False, False)
def _makeInvoices(self, cr, uid, context={}): invoices = {} invoice_ids = [] create_ids=[] tax_ids=[] inv_create = 0 inv_reject = 0 inv_rej_reason = "" list_inv = [] obj_event_reg = self.pool.get('event.registration') obj_lines = self.pool.get('account.invoice.line') inv_obj = self.pool.get('account.invoice') data_even...
journal_id = context['journal_id'] period_id = context['period_id'] journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date: period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'...
journal_id = context.get('journal_id',False) period_id = context.get('period_id',False) if journal_id: journal = self.pool.get('account.journal').browse(cr, uid, [journal_id])[0] if journal.allow_date and period_id: period = self.pool.get('account.period').browse(cr, uid, [period_id])[0] if not time.strptime(vals['date...
def _check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} if 'date' in vals.keys(): if 'journal_id' in vals and 'journal_id' not in context: journal_id = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: period_id = vals['period_id'] elif 'journal_id' not i...
lang=part.lang context.update({'lang': lang})
if part.lang: context.update({'lang': part.lang})
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...
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, context=None):
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):
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, context=None): # note: will call product_id_change_unit_price_inv with context...
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, context=ctx)
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id=currency_id, context=ctx)
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, context=None): # note: will call product_id_change_unit_price_inv with context...
"AND " + self.query +" " \
def set_context(self, objects, data, ids, report_type=None): obj_move = self.pool.get('account.move.line') self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {})) ctx2 = data['form'].get('used_context',{}).copy() ctx2.update({'initial_bal': True}) self.init_query = obj...
objects = self.pool.get('res.partner').browse(self.cr, self.uid, new_ids)
objects = obj_partner.browse(self.cr, self.uid, new_ids)
def set_context(self, objects, data, ids, report_type=None): obj_move = self.pool.get('account.move.line') self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {})) ctx2 = data['form'].get('used_context',{}).copy() ctx2.update({'initial_bal': True}) self.init_query = obj...
ids = [x[1] for x in data['form']['pickings']]
ids = data['form']['pickings'][0][2]
def _make_packing(obj, cursor, user, data, context): wkf_service = netsvc.LocalService('workflow') pool = pooler.get_pool(cursor.dbname) picking_obj = pool.get('stock.picking') ids = [x[1] for x in data['form']['pickings']] picking_obj.force_assign(cursor, user, ids) picking_obj.action_move(cursor, user, ids) for pick...
return open(os.path.join( tools.config['addons_path'], 'hr/image', 'photo.png'), 'rb') .read().encode('base64')
paths = tools.config['addons_path'].split(",") for path in paths: full_path = os.path.join(path, 'hr/image', 'photo.png') if os.path.exists(full_path): return open(full_path,'rb') .read().encode('base64') raise Exception("photo.png could not be found")
def _get_photo(self, cr, uid, context=None): return open(os.path.join( tools.config['addons_path'], 'hr/image', 'photo.png'), 'rb') .read().encode('base64')
if not company_id or 'company_id' in defaults: return defaults
if not company_id or 'company_id' not in fields_list: return defaults
def default_get(self, cr, uid, fields_list=None, context=None): """ get default company if any, and the various other fields from the company's fields """ defaults = super(base_setup_company, self)\ .default_get(cr, uid, fields_list=fields_list, context=context)
def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): """Modifies only one event record out of virtual recurrent events and creates new event as a specific instance of a Recurring Event", @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the ...
def modify_this(self, cr, uid, event_id, defaults, real_date, context=None, *args): """Modifies only one event record out of virtual recurrent events and creates new event as a specific instance of a Recurring Event", @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the ...
real_date = data.get('date') data.update(vals) new_id = self.modify_this(cr, uid, event_id, data, \ real_date, context)
vals.update({ 'recurrent_uid': real_event_id, 'recurrent_id': data.get('date'), 'rrule_type': 'none', 'rrule': '' }) new_id = self.copy(cr, uid, real_event_id, default=vals, context=context)
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): """ Overrides orm write method. @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 crm meeting's ids @param vals: Dictionary of ...
event_id = base_calendar_id2real_id(event_id) if not event_id in new_ids: new_ids.append(event_id)
if not real_event_id in new_ids: new_ids.append(real_event_id)
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): """ Overrides orm write method. @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 crm meeting's ids @param vals: Dictionary of ...
bank_statement = {}
def _coda_parsing(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) codafile = data['form']['coda'] journal_code = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context).code def_pay_acc = data['form']['def_payable'] def_rec_acc = data['form']['def_receivable'] str_log = "" err...
'period_id':statement['period_id'],
'period_id':statement['period_id'] or period,
def _coda_parsing(self, cr, uid, data, context): pool = pooler.get_pool(cr.dbname) codafile = data['form']['coda'] journal_code = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context).code def_pay_acc = data['form']['def_payable'] def_rec_acc = data['form']['def_receivable'] str_log = "" err...
(sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty/u.factor)*count(l.product_id))::decimal(16,2) as price_average,
def init(self, cr): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( select el.*, -- (select count(1) from sale_order_line where order_id = s.id) as nbr, (select 1) as nbr, s.date_order as date, s.date_confirm as date_confirm, to_char(s.date_order, 'YYYY') as year, to_...
el.price_average,
def init(self, cr): tools.drop_view_if_exists(cr, 'sale_report') cr.execute(""" create or replace view sale_report as ( select el.*, -- (select count(1) from sale_order_line where order_id = s.id) as nbr, (select 1) as nbr, s.date_order as date, s.date_confirm as date_confirm, to_char(s.date_order, 'YYYY') as year, to_...
'get_end_date':self._get_end_date,
'get_end_date':self._get_end_date, 'print_data':self._print_data,
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(journal_print, self).__init__(cr, uid, name, context=context) self.period_ids = [] self.journal_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'periods': self.periods, 'sum_debit_period': self._sum_debit_per...
purchase_obj = self.pool.get('purchase.order')
def makeInvoices(self, cr, uid, ids, context=None):
'model': fields.char('Object Name', size=64, required=True),
'model': fields.char('Object Name', size=64, required=True, select=1),
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) groups = self.pool.get('res.groups').search(cr, uid, []) groups_br = self.pool...
'state': fields.selection([('manual','Custom Field'),('base','Base Field')],'Manually Created', required=True, readonly=True),
'state': fields.selection([('manual','Custom Field'),('base','Base Field')],'Manually Created', required=True, readonly=True, select=1),
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(ir_model_grid, self).fields_view_get(cr, uid, view_id, view_type, context=context, toolbar=toolbar, submenu=submenu) groups = self.pool.get('res.groups').search(cr, uid, []) groups_br = self.pool...
'name': fields.char('Name', size=64, required=True), 'model_id': fields.many2one('ir.model', 'Object', required=True, domain=[('osv_memory','=', False)]), 'group_id': fields.many2one('res.groups', 'Group', ondelete='cascade'),
'name': fields.char('Name', size=64, required=True, select=True), 'model_id': fields.many2one('ir.model', 'Object', required=True, domain=[('osv_memory','=', False)], select=True), 'group_id': fields.many2one('res.groups', 'Group', ondelete='cascade', select=True),
def create(self, cr, user, vals, context=None): if 'model_id' in vals: model_data = self.pool.get('ir.model').browse(cr, user, vals['model_id']) vals['model'] = model_data.model if context is None: context = {} if context and context.get('manual',False): vals['state'] = 'manual' res = super(ir_model_fields,self).create...
'name': fields.char('XML Identifier', required=True, size=128), 'model': fields.char('Object', required=True, size=64), 'module': fields.char('Module', required=True, size=64), 'res_id': fields.integer('Resource ID'),
'name': fields.char('XML Identifier', required=True, size=128, select=1), 'model': fields.char('Object', required=True, size=64, select=1), 'module': fields.char('Module', required=True, size=64, select=1), 'res_id': fields.integer('Resource ID', select=1),
def unlink(self, cr, uid, *args, **argv): self.call_cache_clearing_methods(cr) res = super(ir_model_access, self).unlink(cr, uid, *args, **argv) return res
nyear = next_date.strftime("%Y") nmonth = str(int(next_date.strftime("%m"))% 12+1) nday = "1" ndate = "%s-%s-%s" % (nyear, nmonth, nday) nseconds = time.mktime(time.strptime(ndate, '%Y-%m-%d')) next_month = datetime.fromtimestamp(nseconds) delta = timedelta(seconds=1) next_date = next_month - delta next_date = next_d...
next_first_date = next_date + relativedelta(day=1,months=1) next_date = next_first_date + relativedelta(days=line.days2)
def compute(self, cr, uid, id, value, date_ref=False, context=None): if not date_ref: date_ref = datetime.now().strftime('%Y-%m-%d') pt = self.browse(cr, uid, id, context=context) amount = value result = [] obj_precision = self.pool.get('decimal.precision') for line in pt.line_ids: prec = obj_precision.precision_get(cr...
rcal = self.export_cal(cr, uid, rdata, context=context)
event_obj = self.pool.get('basic.calendar.event') rcal = event_obj.export_cal(cr, uid, rdata, context=context)
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...
vevent.add(field).value = key1
vevent.add(field).value = key1.upper()
def create_ics(self, cr, uid, datas, name, ical, context=None): """ create calendaring and scheduling information @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """
name = name[-4] ext = '.ics'
name = name[:-4] ext = True
def _child_get(self, cr, name=False, parent_id=False, domain=None): dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('collection_id','=',self.dir_id)] ext = False if name and name.endswith('.ics'): name = name[-4] ext = '.ics' if name: where.append((...
for calender in fil_obj.browse(cr, uid, ids, context=ctx): if not ext: res.append(node_calendar(calender.name, self, self.context, calender)) else: res.append(res_node_calendar(name, self, self.context, calender))
for cal in fil_obj.browse(cr, uid, ids, context=ctx): if (not name) or not ext: res.append(node_calendar(cal.name, self, self.context, cal)) if (not name) or ext: res.append(res_node_calendar(cal.name+'.ics', self, self.context, cal))
def _child_get(self, cr, name=False, parent_id=False, domain=None): dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) where = [('collection_id','=',self.dir_id)] ext = False if name and name.endswith('.ics'): name = name[-4] ext = '.ics' if name: where.append((...
res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale'))], limit=1)
res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv, 'sale')), ('refund_journal', '=', refund_journal.get(type_inv, False))], limit=1)
def _get_journal(self, cr, uid, context): if context is None: context = {} type_inv = context.get('type', 'out_invoice') type2journal = {'out_invoice': 'sale', 'in_invoice': 'purchase', 'out_refund': 'sale', 'in_refund': 'purchase'} journal_obj = self.pool.get('account.journal') res = journal_obj.search(cr, uid, [('typ...
ean = pack.ean
ean = pack.ean or _('(n/a)')
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): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select ...
warn_msg = _("You selected a quantity of %d Units.\nBut it's not compatible with the selected packaging.\nHere is a proposition of quantities according to the packaging: ") % (qty) warn_msg = warn_msg + "\n\n" + _("EAN: ") + str(ean) + _(" Quantity: ") + str(qty_pack) + _(" Type of ul: ") + str(type_ul.name)
warn_msg = _("You selected a quantity of %d Units.\n" "But it's not compatible with the selected packaging.\n" "Here is a proposition of quantities according to the packaging:\n\n" "EAN: %s Quantity: %s Type of ul: %s") % \ (qty, ean, qty_pack, type_ul.name)
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): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select ...
if 'text' in fields:
if include_original == True and 'text' in fields:
def get_reply_defaults(self, cr, uid, fields, context=None): """ This function gets default values for reply mail """ hist_obj = self.pool.get('crm.case.history') res_ids = context and context.get('active_ids', []) or [] res = {} for hist in hist_obj.browse(cr, uid, res_ids): model = hist.log_id.model_id.model model_po...
'amount': fields.float('Total', readonly=True, select=True),
def init(self, cr): tools.drop_view_if_exists(cr, 'report_sales_by_user_pos_month') cr.execute(""" create or replace view report_sales_by_user_pos_month as ( select min(po.id) as id, to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text as date_order, po.user_id as user_id, sum(pol.qty)as qty, sum((pol.price_un...
'amount': fields.float('Total', readonly=True, select=True),
def init(self, cr): tools.drop_view_if_exists(cr, 'report_sales_by_margin_pos') cr.execute(""" create or replace view report_sales_by_margin_pos as ( select min(pol.id) as id, po.user_id as user_id, pt.name as product_name, to_char(date_trunc('day',po.date_order),'YYYY-MM-DD')::text as date_order, sum(pol.qty) as qty, ...
select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty
select stock.date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty
def init(self, cr): tools.drop_view_if_exists(cr, 'report_products_to_received_planned') cr.execute(""" create or replace view report_products_to_received_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id =...
select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty
select stock.date_planned, min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty
def init(self, cr): tools.drop_view_if_exists(cr, 'report_products_to_received_planned') cr.execute(""" create or replace view report_products_to_received_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id =...
select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty
select stock.date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty
def init(self, cr): tools.drop_view_if_exists(cr, 'report_delivery_products_planned') cr.execute(""" create or replace view report_delivery_products_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock...
select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty
select stock.date_planned, min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty
def init(self, cr): tools.drop_view_if_exists(cr, 'report_delivery_products_planned') cr.execute(""" create or replace view report_delivery_products_planned as ( select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty from stock_picking picking inner join stock_move stock on picking.id = stock...
result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids])
def _product_value(self, cr, uid, ids, field_names, arg, context=None): """Computes stock value (real and virtual) for a product, as well as stock qty (real and virtual). @param field_names: Name of field @return: Dictionary of values """ result = dict([(i, {}.fromkeys(field_names, 0.0)) for i in ids])
arch += '<graph string="%s" type="%s" orientation="%s">' % (report.name, report.view_graph_type, report.view_graph_orientation)
orientation_eval = {'horz':'horizontal','vert' :'vertical'} orientation = eval(report.view_graph_orientation,orientation_eval) arch +='<graph string="%s" type="%s" orientation="%s">' % (report.name, report.view_graph_type, orientation) i = 0
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Overrides orm field_view_get. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @return: Dictionary of Fields, arch and toolbar. """ if not con...
i = 0
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): """ Overrides orm field_view_get. @param cr: the current row, from the database cursor, @param user: the current user’s ID for security checks, @return: Dictionary of Fields, arch and toolbar. """ if not con...
groupby.append(t+'.'+f.field_id.name)
def _sql_query_get(self, cr, uid, ids, prop, unknow_none, context, where_plus=[], limit=None, offset=None): """ Get sql query which return on sql_query field. @return: Dictionary of sql query. """ result = {} for obj in self.browse(cr, uid, ids): fields = [] groupby = [] i = 0 for f in obj.field_ids: # Allowing to use ...
def check_date(self, cr, uid, vals, context=None, check=True):
def _check_date(self, cr, uid, vals, context=None, check=True):
def check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} if 'date' in vals.keys(): if 'journal_id' in vals and 'journal_id' not in context: journal_id = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: period_id = vals['period_id'] elif 'journal_id' not in...
period=self.pool.get('account.period').browse(cr,uid,[period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') and time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'):
period = self.pool.get('account.period').browse(cr,uid,[period_id])[0] if not time.strptime(vals['date'],'%Y-%m-%d')>=time.strptime(period.date_start,'%Y-%m-%d') or not time.strptime(vals['date'],'%Y-%m-%d')<=time.strptime(period.date_stop,'%Y-%m-%d'):
def check_date(self, cr, uid, vals, context=None, check=True): if context is None: context = {} if 'date' in vals.keys(): if 'journal_id' in vals and 'journal_id' not in context: journal_id = vals['journal_id'] if 'period_id' in vals and 'period_id' not in context: period_id = vals['period_id'] elif 'journal_id' not in...
self.check_date(cr, uid, vals, context, check)
self._check_date(cr, uid, vals, context, check)
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): if not context: context={} if vals.get('account_tax_id', False): raise osv.except_osv(_('Unable to change tax !'), _('You can not change the tax, you should remove and recreate lines !')) self.check_date(cr, uid, vals, context, check) acc...
self.check_date(cr, uid, vals, context, check)
self._check_date(cr, uid, vals, context, check)
def create(self, cr, uid, vals, context=None, check=True): account_obj = self.pool.get('account.account') tax_obj=self.pool.get('account.tax') if context is None: context = {} self.check_date(cr, uid, vals, context, check) if ('account_id' in vals) and not account_obj.read(cr, uid, vals['account_id'], ['active'])['acti...
statement_id = context.get('statement_id', False) if not statement_id: return {} data = self.read(cr, uid, ids, context=context)[0] line_ids = data['line_ids'] if not line_ids: return {}
def populate_statement(self, cr, uid, ids, context=None):
data = self.read(cr, uid, ids, context=context)[0] line_ids = data['line_ids']
def populate_statement(self, cr, uid, ids, context=None):
if not line_ids: return {} statement_id = 'statement_id' in context and context['statement_id']
def populate_statement(self, cr, uid, ids, context=None):
res = mailgate_pool.get_partner(cr, uid, msg.get('from'))
res = mailgate_pool.get_partner(cr, uid, msg.get('from') or msg.get_unixfrom())
def message_new(self, cr, uid, msg, context): """ Automatically calls when new email message arrives @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks """
vals.update({ 'description': msg['body'] }) if msg.get('priority', False):
if msg.get('priority'):
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of update mail’s IDs """ if isinstance(ids, (str, int, long)): id...
if res and maps.get(res.group(1).lower(), False):
if res and maps.get(res.group(1).lower()):
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of update mail’s IDs """ if isinstance(ids, (str, int, long)): id...
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 20),
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 20),
def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): move = {} for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): for line in r.line_partial_ids: move[line.move_id.id] = True for line in r.line_id: move[line.move_id.id] = True
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount'], 50),
'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id'], 50),
def _get_invoice_from_reconcile(self, cr, uid, ids, context=None): move = {} for r in self.pool.get('account.move.reconcile').browse(cr, uid, ids): for line in r.line_partial_ids: move[line.move_id.id] = True for line in r.line_id: move[line.move_id.id] = True
debit = credit = 0.0 context.update({'date':inv.date_invoice}) context_unreconciled=context.copy()
if inv.reconciled: res[inv.id] = 0.0 continue inv_total = inv.amount_total context_unreconciled = context.copy()
def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} if context is None: context = {}
debit_tmp = lines.debit credit_tmp = lines.credit if inv.company_id.currency_id.id <> inv.currency_id.id: if not inv.reconciled: context.update({'date':lines.date}) context_unreconciled.update({'date':lines.date}) if lines.amount_currency < 0: credit_tmp=abs(cur_obj.compute(cr, uid, lines.currency_id.id, inv.compan...
if lines.currency_id and lines.currency_id.id == inv.currency_id.id: if inv.type in ('out_invoice','in_refund'): inv_total += lines.amount_currency else: inv_total -= lines.amount_currency
def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} if context is None: context = {}
debit+=debit_tmp credit+=credit_tmp if not inv.amount_total: result = 0.0 elif inv.type in ('out_invoice','in_refund'): amount = credit-debit result = inv.amount_total - amount else: amount = debit-credit result = inv.amount_total - amount res[inv.id] = not self.pool.get('res.currency').is_zero(cr, uid, inv.company_i...
context_unreconciled.update({'date': lines.date}) amount_in_invoice_currency = cur_obj.compute(cr, uid, inv.company_id.currency_id.id, inv.currency_id.id,abs(lines.debit-lines.credit),round=False,context=context_unreconciled) inv_total -= amount_in_invoice_currency result = inv_total res[inv.id] = self.pool.get('res....
def _amount_residual(self, cr, uid, ids, name, args, context=None): res = {} if context is None: context = {}
res = collection_obj.get_schedule_inbox_URL(cr, uid, ids, context=ctx)
res = dirobj.get_schedule_inbox_URL(cr, uid, ids, context=ctx)
def _get_caldav_schedule_inbox_URL(self, cr): import xml.dom.minidom import urllib dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) ids = [self.dir_id] res = collection_obj.get_schedule_inbox_URL(cr, uid, ids, context=ctx) doc = xml.dom.minidom.getDOMImplemen...
res = collection_obj.get_schedule_outbox_URL(cr, uid, ids, context=ctx)
res = dirobj.get_schedule_outbox_URL(cr, uid, ids, context=ctx)
def _get_caldav_schedule_outbox_URL(self, cr): import xml.dom.minidom import urllib dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() ctx.update(self.dctx) ids = [self.dir_id] res = collection_obj.get_schedule_outbox_URL(cr, uid, ids, context=ctx) doc = xml.dom.minidom.getDOMImplem...
launch_date = datetime.now()
launch_date = date
def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return
launch_date = datetime.now() + transition._delta()
launch_date = date + transition._delta()
def _process_one(self, cr, uid, workitem, context=None): if workitem.state != 'todo': return
def action_cancel(self, cr, uid, ids, context=None): res = super(stock_picking, self).action_cancel(cr, uid, ids, context=context) for pick in self.browse(cr, uid, ids, context=context): call_ship_end = True if pick.sale_id: for picks in pick.sale_id.picking_ids: if picks.state not in ('done', 'cancel'): call_ship_end ...
def action_cancel(self, cr, uid, ids, context=None): res = super(stock_picking, self).action_cancel(cr, uid, ids, context=context) for pick in self.browse(cr, uid, ids, context=context): call_ship_end = True if pick.sale_id: for picks in pick.sale_id.picking_ids: if picks.state not in ('done', 'cancel'): call_ship_end ...
'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade', required=True), 'phase_id': fields.many2one('project.phase', 'Project Phase', required=True),
'resource_id': fields.many2one('resource.resource', 'Resource', required=True), 'phase_id': fields.many2one('project.phase', 'Project Phase', ondelete='cascade', required=True),
def set_done(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'done'}) return True
sub_total[i]= entry.price_subtotal and entry.price_subtotal or 0.00
sub_total[i]= entry.price_subtotal and entry.price_subtotal
def sale_order_lines(self,sale_order): result =[] sub_total={} info=[] order_lines=[] res={} list_in_seq=[] ids = self.pool.get('sale.order.line').search(self.cr, self.uid, [('order_id', '=', sale_order.id)]) for id in range(0,len(ids)): order = self.pool.get('sale.order.line').browse(self.cr, self.uid,ids[id], self.co...
res['note']=entry.notes
res['note']=entry.notes or ''
def sale_order_lines(self,sale_order): result =[] sub_total={} info=[] order_lines=[] res={} list_in_seq=[] ids = self.pool.get('sale.order.line').search(self.cr, self.uid, [('order_id', '=', sale_order.id)]) for id in range(0,len(ids)): order = self.pool.get('sale.order.line').browse(self.cr, self.uid,ids[id], self.co...
def _get_new_period_start(self,cr,uid,context={}):
def _get_new_period_start(self, cr, uid, context=None):
def _get_new_period_start(self,cr,uid,context={}): cr.execute("select max(date_stop) from stock_period") result=cr.fetchone() last_date = result and result[0] or False if last_date: period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1) period_start = period_start - RelativeDateTim...
def create_period_weekly(self,cr, uid, ids, context={}): res=self.create_period(cr, uid, ids, context, 6, 'Weekly')
def create_period_weekly(self, cr, uid, ids, context=None): res = self.create_period(cr, uid, ids, context, 6, 'Weekly')
def _get_new_period_start(self,cr,uid,context={}): cr.execute("select max(date_stop) from stock_period") result=cr.fetchone() last_date = result and result[0] or False if last_date: period_start = mx.DateTime.strptime(last_date,"%Y-%m-%d %H:%M:%S")+ RelativeDateTime(days=1) period_start = period_start - RelativeDateTim...
def create_period_monthly(self,cr, uid, ids, context={},interval=1): for p in self.browse(cr, uid, ids, context):
def create_period_monthly(self,cr, uid, ids, interval=1, context=None): for p in self.browse(cr, uid, ids, context=context):
def create_period_weekly(self,cr, uid, ids, context={}): res=self.create_period(cr, uid, ids, context, 6, 'Weekly') return { 'view_type': 'form', "view_mode": 'tree', 'res_model': 'stock.period', 'type': 'ir.actions.act_window', }
'type': 'ir.actions.act_window', } def create_period(self,cr, uid, ids, context={}, interval=0, name='Daily'): for p in self.browse(cr, uid, ids, context):
'type': 'ir.actions.act_window', } def create_period(self, cr, uid, ids, interval=0, name='Daily', context=None): for p in self.browse(cr, uid, ids, context=context):
def create_period_monthly(self,cr, uid, ids, context={},interval=1): for p in self.browse(cr, uid, ids, context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')<p.date_stop: de = ds + RelativeDateTime(months=interval, minutes=-1) self.pool.get('stock.period').create(...
'name': fields.char('Period Name', size=64),
'name': fields.char('Period Name', size=64, required=True),
def create_period(self,cr, uid, ids, context={}, interval=0, name='Daily'): for p in self.browse(cr, uid, ids, context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')<p.date_stop: de = ds + RelativeDateTime(days=interval, minutes =-1) if name=='Daily': new_name=de.s...
'state' : lambda * a : 'draft'
'state': 'draft'
def create_period(self,cr, uid, ids, context={}, interval=0, name='Daily'): for p in self.browse(cr, uid, ids, context): dt = p.date_start ds = mx.DateTime.strptime(p.date_start, '%Y-%m-%d') while ds.strftime('%Y-%m-%d')<p.date_stop: de = ds + RelativeDateTime(days=interval, minutes =-1) if name=='Daily': new_name=de.s...
'copy_forecast' : fields.boolean('Copy Last Forecast', help="Copy quantities from last Stock and Sale Forecast."),
'copy_forecast': fields.boolean('Copy Last Forecast', help="Copy quantities from last Stock and Sale Forecast."), } _defaults = { 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.sale.forecast.createlines', context=c),
# def _get_latest_period(self,cr,uid,context={}):
_defaults = { 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.sale.forecast.createlines', context=c), } def create_forecast(self,cr, uid, ids, context={}):
def create_forecast(self, cr, uid, ids, context=None):
# def _get_latest_period(self,cr,uid,context={}):
forecast_obj=self.pool.get('stock.sale.forecast') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context): prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.template')
forecast_obj = self.pool.get('stock.sale.forecast') mod_obj = self.pool.get('ir.model.data') prod_categ_obj = self.pool.get('product.category') template_obj = self.pool.get('product.template') for f in self.browse(cr, uid, ids, context=context):
def create_forecast(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') forecast_obj=self.pool.get('stock.sale.forecast') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context): prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.t...
'state': lambda *args: 'draft',
'state': 'draft',
def create_forecast(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') forecast_obj=self.pool.get('stock.sale.forecast') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context): prod_categ_obj=self.pool.get('product.category') template_obj=self.pool.get('product.t...
def unlink(self, cr, uid, ids, context={}):
def unlink(self, cr, uid, ids, context=None):
def action_validate(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state':'validated','user_id':uid}) return True
def onchange_company(self, cr, uid, ids, company_id):
def onchange_company(self, cr, uid, ids, company_id=False):
def onchange_company(self, cr, uid, ids, company_id): result = {} if company_id: result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False return {'value': result}
if company_id: result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False
if not company_id: return result result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False
def onchange_company(self, cr, uid, ids, company_id): result = {} if company_id: result['warehouse_id'] = False result['analyzed_user_id'] = False result['analyzed_dept_id'] = False result['analyzed_warehouse_id'] = False return {'value': result}
def product_id_change(self, cr, uid, ids, product_id): ret={}
def product_id_change(self, cr, uid, ids, product_id=False): ret = {}
def product_id_change(self, cr, uid, ids, product_id): ret={} if product_id: product_rec = self.pool.get('product.product').browse(cr, uid, product_id) ret['product_uom'] = product_rec.uom_id.id ret['product_uom_categ'] = product_rec.uom_id.category_id.id ret['product_uos_categ'] = product_rec.uos_id and product_rec.u...
def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, active_uom=False ): ret={} val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, active_uom, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = ...
def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, active_uom=False): ret = {} if not ids: return {} if product_uom: val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, active_uom, {}) coeff_def2uom, round_value = self._from_default_uom_factor( ...
def onchange_uom(self, cr, uid, ids, product_uom=False, product_qty=0.0, active_uom=False ): ret={} val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, active_uom, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = ...
ret={}
ret = {} if not ids: return {}
def product_amt_change(self, cr, uid, ids, product_amt = 0.0, product_uom=False): ret={} round_value = 1 if product_amt: coeff_def2uom = 1 val1 = self.browse(cr, uid, ids) val = val1[0] if (product_uom != val.product_id.uom_id.id): coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {...
def _to_default_uom_factor(self, cr, uid, val, uom_id, context):
def _to_default_uom_factor(self, cr, uid, val, uom_id, context=None):
def _to_default_uom_factor(self, cr, uid, val, uom_id, context): uom_obj = self.pool.get('product.uom') uom = uom_obj.browse(cr, uid, uom_id, context=context) coef = uom.factor if uom.category_id.id <> val.product_id.uom_id.category_id.id: coef = coef / val.product_id.uos_coeff return val.product_id.uom_id.factor / co...
def _sales_per_company(self, cr, uid, so, so_line, company, ):
def _sales_per_company(self, cr, uid, so, so_line, company):
def _sales_per_company(self, cr, uid, so, so_line, company, ): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(s...
"WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(so), company))
"WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)", (tuple(so_line), tuple(so), company))
def _sales_per_company(self, cr, uid, so, so_line, company, ): cr.execute("SELECT sum(sol.product_uom_qty) FROM sale_order_line AS sol LEFT JOIN sale_order AS s ON (s.id = sol.order_id) " \ "WHERE (sol.id IN %s) AND (s.state NOT IN (\'draft\',\'cancel\')) AND (s.id IN %s) AND (s.company_id=%s)"%(tuple(so_line), tuple(s...
def onchange_company(self, cr, uid, ids, company_id):
def onchange_company(self, cr, uid, ids, company_id=False):
def onchange_company(self, cr, uid, ids, company_id): result = {} if company_id: result['warehouse_id2'] = False return {'value': result}
def create_planning(self,cr, uid, ids, context={}):
def create_planning(self,cr, uid, ids, context=None): if context is None: context = {}
def create_planning(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') planning_obj=self.pool.get('stock.planning') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast ...
def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context):
def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context=None):
def create_planning(self,cr, uid, ids, context={}): product_obj = self.pool.get('product.product') planning_obj=self.pool.get('stock.planning') mod_obj =self.pool.get('ir.model.data') for f in self.browse(cr, uid, ids, context=context): if f.forecasted_products: cr.execute("SELECT product_id \ FROM stock_sale_forecast ...
if not context: context = {} product_obj = self.pool.get('product.product')
def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context):
product_obj = self.pool.get('product.product')
def _get_in_out(self, cr, uid, val, date_start, date_stop, direction, done, context):
def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context):
def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context=None):
def _get_outgoing_before(self, cr, uid, val, date_start, date_stop, context): cr.execute("SELECT sum(planning.planned_outgoing), planning.product_uom \ FROM stock_planning AS planning \ LEFT JOIN stock_period AS period \ ON (planning.period_id = period.id) \ WHERE (period.date_stop >= %s) AND (period.date_stop <= %s) \...
def _get_forecast(self, cr, uid, ids, field_names, arg, context):
def _get_forecast(self, cr, uid, ids, field_names, arg, context=None):
def _to_planning_uom(self, cr, uid, val, qtys, context): res_qty = 0 if qtys: uom_obj = self.pool.get('product.uom') for qty, prod_uom in qtys: coef = self._to_default_uom_factor(cr, uid, val, prod_uom, context=context) res_coef, round_value = self._from_default_uom_factor(cr, uid, val, val.product_uom.id, context=cont...
def _get_stock_start(self, cr, uid, val, date, context):
def _get_stock_start(self, cr, uid, val, date, context=None):
def _get_stock_start(self, cr, uid, val, date, context): context['from_date'] = None context['to_date'] = date locations = [val.warehouse_id.lot_stock_id.id,] if not val.stock_only: locations.extend([val.warehouse_id.lot_input_id.id, val.warehouse_id.lot_output_id.id]) context['location'] = locations context['compute_c...
def _get_op(self, cr, uid, ids, field_names, arg, context):
def _get_op(self, cr, uid, ids, field_names, arg, context=None):
def _get_op(self, cr, uid, ids, field_names, arg, context): # op = OrderPoint res = {} for val in self.browse(cr, uid, ids, context=context): res[val.id]={} cr.execute("SELECT product_min_qty, product_max_qty, product_uom \ FROM stock_warehouse_orderpoint \ WHERE warehouse_id = %s AND product_id = %s AND active = 'TR...
def onchange_company(self, cr, uid, ids, company_id):
def onchange_company(self, cr, uid, ids, company_id=False):
def _get_op(self, cr, uid, ids, field_names, arg, context): # op = OrderPoint res = {} for val in self.browse(cr, uid, ids, context=context): res[val.id]={} cr.execute("SELECT product_min_qty, product_max_qty, product_uom \ FROM stock_warehouse_orderpoint \ WHERE warehouse_id = %s AND product_id = %s AND active = 'TR...