rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
cr.execute("DROP LANGUAGE IF EXISTS plpgsql CASCADE;")
def execute(self, cr, uid, ids, context=None): """ This function is used to create contact and address from existing partner address """ obj = self.pool.get("base.contact.installer").browse(cr, uid, uid, context=context) if obj.migrate: cr.execute("""DROP TRIGGER IF EXISTS contactjob on res_partner_contact; DROP LANGUAGE IF EXISTS plpgsql CASCADE; CREATE LANGUAGE plpgsql ; CREATE OR REPLACE FUNCTION add_to_job() RETURNS TRIGGER AS $contactjob$ DECLARE new_name varchar; new_phonenum varchar; BEGIN IF(TG_OP='INSERT') THEN INSERT INTO res_partner_job(contact_id, address_id, function, state) VALUES(NEW.id, NEW.website::integer,NEW.first_name, 'current'); UPDATE res_partner_contact set first_name=Null, website=Null, active=True where id=NEW.id; END IF; RETURN NEW; END; $contactjob$ LANGUAGE plpgsql; CREATE TRIGGER contactjob AFTER INSERT ON res_partner_contact FOR EACH ROW EXECUTE PROCEDURE add_to_job();""")
'work_phone': fields.related('address_id', 'phone', type='char', size=32, string='Work Phone', readonly=True), 'work_email': fields.related('address_id', 'email', type='char', size=240, string='Work E-mail'),
'work_phone': fields.char('Work Phone', size=32, readonly=False), 'work_email': fields.char('Work E-mail', size=240),
def job_open(self, cr, uid, ids, *args): self.write(cr, uid, ids, {'state': 'open'}) return True
first_monday = start_date - relativedelta(days=start_date.day_of_week) last_monday = end_date + relativedelta(days=7 - end_date.day_of_week)
first_monday = start_date - relativedelta(days=start_date.date().weekday()) last_monday = end_date + relativedelta(days=7 - end_date.date().weekday())
def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.day_of_week) last_monday = end_date + relativedelta(days=7 - end_date.day_of_week) if last_monday < first_monday: first_monday, last_monday = last_monday, first_monday
week_wh[ldt.day_of_week] = week_wh.get(ldt.day_of_week, 0) + (dt - ldt).hours
week_wh[ldt.date().weekday()] = week_wh.get(ldt.date().weekday(), 0) + (dt - ldt).hours
def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.day_of_week) last_monday = end_date + relativedelta(days=7 - end_date.day_of_week) if last_monday < first_monday: first_monday, last_monday = last_monday, first_monday
if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)]) if move_lines: raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines'))
if context is None: context = {} for journal in self.browse(cr, uid, ids, context=context): if 'company_id' in vals and journal.company_id.id != vals['company_id']: move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)]) if move_lines: raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines'))
def write(self, cr, uid, ids, vals, context=None): if 'company_id' in vals: move_lines = self.pool.get('account.move.line').search(cr, uid, [('journal_id', 'in', ids)]) if move_lines: raise osv.except_osv(_('Warning !'), _('You cannot modify company of this journal as its related record exist in Entry Lines')) return super(account_journal, self).write(cr, uid, ids, vals, context=context)
view_id = type_map.get(type, 'general')
view_id = type_map.get(type, 'account_journal_view')
def onchange_type(self, cr, uid, ids, type, currency): obj_data = self.pool.get('ir.model.data') user_pool = self.pool.get('res.users')
'partner_id': fields.related('address_id','partner_id',type='many2one',relation='res.partner',string='Partner'),
'partner_id': fields.related('address_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True),
def create(self, cr, user, vals, context=None): if ('name' not in vals) or (vals.get('name')=='/'): seq_obj_name = 'stock.picking.' + vals['type'] vals['name'] = self.pool.get('ir.sequence').get(cr, user, seq_obj_name) new_id = super(stock_picking, self).create(cr, user, vals, context) return new_id
if args is None:
if not len(args):
def name_search(self, cr, user, name, args=None, operator='ilike', context={}): if args is None: args = [] ids = [] if name: ids = self.search(cr, user, [('obj_num','=',int(name))] + args) if not ids: ids = self.search(cr, user, [('name',operator,name)] + args) return self.name_get(cr, user, ids)
'date_planned': procurement.date_planned,
'date_expected': procurement.date_planned,
def action_confirm(self, cr, uid, ids, context={}): """ Confirms procurement and writes exception message if any. @return: True """ move_obj = self.pool.get('stock.move') for procurement in self.browse(cr, uid, ids): if procurement.product_qty <= 0.00: raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity in Procurement Order(s), it should not be less than 1!')) if procurement.product_id.type in ('product', 'consu'): if not procurement.move_id: source = procurement.location_id.id if procurement.procure_method == 'make_to_order': source = procurement.product_id.product_tmpl_id.property_stock_procurement.id id = move_obj.create(cr, uid, { 'name': 'PROC:' + procurement.name, 'location_id': source, 'location_dest_id': procurement.location_id.id, 'product_id': procurement.product_id.id, 'product_qty': procurement.product_qty, 'product_uom': procurement.product_uom.id, 'date_planned': procurement.date_planned, 'state': 'draft', 'company_id': procurement.company_id.id, }) move_obj.action_confirm(cr, uid, [id], context=context) self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1}) message = _("Procurement '%s' is running.") % procurement.name self.log(cr, uid, procurement.id, message) self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''}) return True
message['body'] = tools.ustr(message['body'].decode(encoding))
message['body'] = self._to_decode(message['body'], [encoding]) from_mail = self._decode_header(message['From'])
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(tools.ustr(msg).encode('utf-8')) subject = "[%s] %s" %(res_id, message['Subject']) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
Hello %s,
Hello %s,""" % (from_mail)) body += _(""" Your Request ID: %s""") % (res_id) body += _("""
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(tools.ustr(msg).encode('utf-8')) subject = "[%s] %s" %(res_id, message['Subject']) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
Your Request ID: %s
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(tools.ustr(msg).encode('utf-8')) subject = "[%s] %s" %(res_id, message['Subject']) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
""") %(message['From'], res_id, message['body'])
""") % (self._to_decode(message['body'], [encoding]))
def email_send(self, cr, uid, model, res_id, msg, from_email=False, email_default=False): """This function Sends return email on submission of Fetched email in OpenERP database @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 model: OpenObject Model @param res_id: Id of the record of OpenObject model created from the Email details @param msg: Email details @param email_default: Default Email address in case of any Problem """ history_pool = self.pool.get('mailgate.message') model_pool = self.pool.get(model) from_email = from_email or tools.config.get('email_from', None) message = email.message_from_string(tools.ustr(msg).encode('utf-8')) subject = "[%s] %s" %(res_id, message['Subject']) #msg_mails = [] #mails = [self._decode_header(message['From']), self._decode_header(message['To'])] #mails += self._decode_header(message.get('Cc', '')).split(',')
picking_id = self.pool.get('stock.picking').create(cr, uid, {
picking_id =picking_obj.create(cr, uid, {
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') 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 = self.pool.get('stock.picking').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 = self.pool.get('stock.move').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'): self.pool.get('stock.move').write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = self.pool.get('procurement.order').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: self.pool.get('stock.move').write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
move_id = self.pool.get('stock.move').create(cr, uid, {
move_id =move_obj.create(cr, uid, {
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') 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 = self.pool.get('stock.picking').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 = self.pool.get('stock.move').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'): self.pool.get('stock.move').write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = self.pool.get('procurement.order').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: self.pool.get('stock.move').write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
self.pool.get('stock.move').write(cr,uid, [proc.move_id.id], {
move_obj.write(cr,uid, [proc.move_id.id], {
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') 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 = self.pool.get('stock.picking').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 = self.pool.get('stock.move').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'): self.pool.get('stock.move').write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = self.pool.get('procurement.order').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: self.pool.get('stock.move').write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
proc_id = self.pool.get('procurement.order').create(cr, uid, {
proc_id = proc_obj.create(cr, uid, {
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') 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 = self.pool.get('stock.picking').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 = self.pool.get('stock.move').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'): self.pool.get('stock.move').write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = self.pool.get('procurement.order').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: self.pool.get('stock.move').write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
self.pool.get('stock.move').write(cr, uid, [proc.move_id.id],
move_obj.write(cr, uid, [proc.move_id.id],
def action_move_create(self, cr, uid, ids,context=None): proc_obj = self.pool.get('procurement.order') move_obj = self.pool.get('stock.move') location_obj = self.pool.get('stock.location') 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 = self.pool.get('stock.picking').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 = self.pool.get('stock.move').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'): self.pool.get('stock.move').write(cr,uid, [proc.move_id.id], { 'state':'waiting' }, context=context) proc_id = self.pool.get('procurement.order').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: self.pool.get('stock.move').write(cr, uid, [proc.move_id.id], {'location_id':proc.location_id.id})
line_amount = line[2].get('amount')
line_amount = line[2] and line[2].get('amount',0.0) or 0.0
def onchange_price(self, cr, uid, ids, line_ids, tax_id, partner_id=False, context={}): tax_pool = self.pool.get('account.tax') partner_pool = self.pool.get('res.partner') position_pool = self.pool.get('account.fiscal.position') res = { 'tax_amount': False, 'amount': False, } voucher_total = 0.0 voucher_line_ids = []
def _get_cash_box_lines(self, cr, uid, ids, context={}):
def _get_cash_open_box_lines(self, cr, uid, ids, context={}):
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
def _get_cash_close_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((0, 0, dct)) return res
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
'starting_details_ids':_get_cash_box_lines, 'ending_details_ids':_get_cash_box_lines
'starting_details_ids':_get_cash_open_box_lines, 'ending_details_ids':_get_cash_open_box_lines
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
tuple = (proba * 100, benefit)
tuple_benefit = (proba * 100, benefit)
def create(self, cr, uid, ids, datas, context={}):
responsible_data[userid].append(tuple)
responsible_data[userid].append(tuple_benefit)
def create(self, cr, uid, ids, datas, context={}):
tuple = (proba * 100, cost, benefit) data.append(tuple)
tuple_benefit = (proba * 100, cost, benefit) data.append(tuple_benefit)
def create(self, cr, uid, ids, datas, context={}):
usage = 'customer'
src_usage = dest_usage = None
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') usage = 'customer' pick = picking_obj.browse(cr, uid, context['active_id'], context=context) if pick.invoice_state == 'invoiced': raise osv.except_osv(_('UserError'), _('Invoice is already created.')) if pick.invoice_state == 'none': raise osv.except_osv(_('UserError'), _('This picking does not require any invoicing.')) if pick.move_lines: usage = pick.move_lines[0].location_id.usage
usage = pick.move_lines[0].location_id.usage if pick.type == 'out' and usage == 'supplier':
src_usage = pick.move_lines[0].location_id.usage dest_usage = pick.move_lines[0].location_dest_id.usage if pick.type == 'out' and dest_usage == 'supplier':
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') usage = 'customer' pick = picking_obj.browse(cr, uid, context['active_id'], context=context) if pick.invoice_state == 'invoiced': raise osv.except_osv(_('UserError'), _('Invoice is already created.')) if pick.invoice_state == 'none': raise osv.except_osv(_('UserError'), _('This picking does not require any invoicing.')) if pick.move_lines: usage = pick.move_lines[0].location_id.usage
elif pick.type == 'out' and usage == 'customer':
elif pick.type == 'out' and dest_usage == 'customer':
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') usage = 'customer' pick = picking_obj.browse(cr, uid, context['active_id'], context=context) if pick.invoice_state == 'invoiced': raise osv.except_osv(_('UserError'), _('Invoice is already created.')) if pick.invoice_state == 'none': raise osv.except_osv(_('UserError'), _('This picking does not require any invoicing.')) if pick.move_lines: usage = pick.move_lines[0].location_id.usage
elif pick.type == 'in' and usage == 'supplier':
elif pick.type == 'in' and src_usage == 'supplier':
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') usage = 'customer' pick = picking_obj.browse(cr, uid, context['active_id'], context=context) if pick.invoice_state == 'invoiced': raise osv.except_osv(_('UserError'), _('Invoice is already created.')) if pick.invoice_state == 'none': raise osv.except_osv(_('UserError'), _('This picking does not require any invoicing.')) if pick.move_lines: usage = pick.move_lines[0].location_id.usage
elif pick.type == 'in' and usage == 'customer':
elif pick.type == 'in' and src_usage == 'customer':
def _get_type(self, cr, uid, context=None): """ To get invoice type. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param ids: The ID or list of IDs if we want more than one @param context: A standard dictionary @return: Invoice type """ if context is None: context = {} picking_obj = self.pool.get('stock.picking') usage = 'customer' pick = picking_obj.browse(cr, uid, context['active_id'], context=context) if pick.invoice_state == 'invoiced': raise osv.except_osv(_('UserError'), _('Invoice is already created.')) if pick.invoice_state == 'none': raise osv.except_osv(_('UserError'), _('This picking does not require any invoicing.')) if pick.move_lines: usage = pick.move_lines[0].location_id.usage
for picking in picking_obj.browse(cr, uid, context.get('active_ids', []), context=context): if picking.invoice_state == '2binvoiced': res = picking_obj.action_invoice_create(cr, uid, [picking.id], journal_id = onshipdata_obj['journal_id'], group=onshipdata_obj['group'], type=self._get_type(picking), context=context) invoice_ids.extend(res.values())
active_ids=context.get('active_ids', []) picking = picking_obj.browse(cr, uid,active_ids, context=context)[0] if onshipdata_obj['group']: res = picking_obj.action_invoice_create(cr, uid,active_ids, journal_id = onshipdata_obj['journal_id'], group=onshipdata_obj['group'], type=self._get_type(picking), context=context) invoice_ids.extend(res.values()) else: res = picking_obj.action_invoice_create(cr, uid,active_ids, journal_id = onshipdata_obj['journal_id'], group=onshipdata_obj['group'], type=self._get_type(picking), context=context) invoice_ids.extend(res.values())
def create_invoice(self, cr, uid, ids, context=None): if context is None: context = {} result = [] picking_obj = self.pool.get('stock.picking') onshipdata_obj = self.read(cr, uid, ids[0], ['journal_id', 'group', 'invoice_date']) if context.get('new_picking', False): onshipdata_obj['id'] = onshipdata_obj.new_picking onshipdata_obj[ids] = onshipdata_obj.new_picking
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context).id
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
return (int(real_id), real_date)
start = datetime.strptime(real_date, "%Y-%m-%d %H:%M:%S") end = start + timedelta(hours=with_date) return (int(real_id), real_date, end.strftime("%Y-%m-%d %H:%M:%S"))
def caldav_id2real_id(caldav_id=None, with_date=False): if caldav_id and isinstance(caldav_id, (str, unicode)): res = caldav_id.split('-') if len(res) >= 2: real_id = res[0] if with_date: real_date = time.strftime("%Y-%m-%d %H:%M:%S", \ time.strptime(res[1], "%Y%m%d%H%M%S")) return (int(real_id), real_date) return int(real_id) return caldav_id and int(caldav_id) or caldav_id
cr.execute("select m.id, m.rrule, m.date, m.exdate \ from " + self._table + " m where m.id in ("\
cr.execute("select m.id, m.rrule, m.date, m.date_deadline, \ m.exdate from " + self._table + \ " m where m.id in ("\
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if isinstance(select, (str, int, long)): ids = [select] else: ids = select result = [] if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, m.date, m.exdate \ from " + self._table + " m where m.id in ("\ + ','.join(map(lambda x: str(x), ids))+")")
if start_date and event_date < start_date:
if start_date and (event_date < start_date):
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if isinstance(select, (str, int, long)): ids = [select] else: ids = select result = [] if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, m.date, m.exdate \ from " + self._table + " m where m.id in ("\ + ','.join(map(lambda x: str(x), ids))+")")
if until_date and event_date > until_date:
if until_date and (event_date > until_date):
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100): if not limit: limit = 100 if isinstance(select, (str, int, long)): ids = [select] else: ids = select result = [] if ids and (base_start_date or base_until_date): cr.execute("select m.id, m.rrule, m.date, m.exdate \ from " + self._table + " m where m.id in ("\ + ','.join(map(lambda x: str(x), ids))+")")
ls = caldav_id2real_id(caldav_id, with_date=True)
ls = caldav_id2real_id(caldav_id, with_date=res.get('duration', 0))
def read(self, cr, uid, ids, fields=None, context={}, load='_classic_read'): if isinstance(ids, (str, int, long)): select = [ids] else: select = ids select = map(lambda x: (x, caldav_id2real_id(x)), select) result = [] if fields and 'date' not in fields: fields.append('date') for caldav_id, real_id in select: res = super(calendar_event, self).read(cr, uid, real_id, fields=fields, context=context, \ load=load) ls = caldav_id2real_id(caldav_id, with_date=True) if not isinstance(ls, (str, int, long)) and len(ls) >= 2: res['date'] = ls[1] res['id'] = caldav_id
obj_inv = self.browse(cr, uid, ids)[0]
inv = self.browse(cr, uid, ids)[0]
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } if obj_inv.journal_id.invoice_sequence_id: sid = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id}) else: number = obj_seq.get_id(cr, uid, 'account.invoice.%s' % invtype, 'code=%s', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
if obj_inv.journal_id.invoice_sequence_id: sid = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id})
if inv.journal_id.invoice_sequence_id: sid = inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': inv.period_id.fiscalyear_id.id})
def action_number(self, cr, uid, ids, *args): cr.execute('SELECT id, type, number, move_id, reference ' \ 'FROM account_invoice ' \ 'WHERE id IN %s', (tuple(ids),)) obj_inv = self.browse(cr, uid, ids)[0] for (id, invtype, number, move_id, reference) in cr.fetchall(): if not number: tmp_context = { 'fiscalyear_id': inv.period_id.fiscalyear_id.id } if obj_inv.journal_id.invoice_sequence_id: sid = obj_inv.journal_id.invoice_sequence_id.id number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id}) else: number = obj_seq.get_id(cr, uid, 'account.invoice.%s' % invtype, 'code=%s', context=tmp_context) if invtype in ('in_invoice', 'in_refund'): ref = reference else: ref = self._convert_ref(cr, uid, number) cr.execute('UPDATE account_invoice SET number=%s ' \ 'WHERE id=%s', (number, id)) cr.execute('UPDATE account_move SET ref=%s ' \ 'WHERE id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_move_line SET ref=%s ' \ 'WHERE move_id=%s AND (ref is null OR ref = \'\')', (ref, move_id)) cr.execute('UPDATE account_analytic_line SET ref=%s ' \ 'FROM account_move_line ' \ 'WHERE account_move_line.move_id = %s ' \ 'AND account_analytic_line.move_id = account_move_line.id', (ref, move_id)) return True
obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0])
if w_id: obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0])
def unsubscribe(self, cr, uid, ids, *args): """ Unsubscribe Auditing Rule on object @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Auddittrail Rule’s IDs. @return: True """ obj_action = self.pool.get('ir.actions.act_window') val_obj = self.pool.get('ir.values') #start Loop for thisrule in self.browse(cr, uid, ids): if thisrule.id in self.__functions: for function in self.__functions[thisrule.id]: setattr(function[0], function[1], function[2]) w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)]) obj_action.unlink(cr, uid, w_id) value = "ir.actions.act_window" + ',' + str(w_id[0]) val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)]) if val_id: res = ir.ir_del(cr, uid, val_id[0]) self.write(cr, uid, [thisrule.id], {"state": "draft"}) #End Loop return True
group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Survey / Manager','Survey / User'))])
group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Tools / Manager','Tools / User'))])
def _get_survey(self, cr, uid, context=None): """ Set the value In survey_id field.
for colname,col in self.pool.get(obj)._columns.items(): if isinstance(col, fields.float):
for colname, col in self.pool.get(obj)._columns.items(): if isinstance(col, (fields.float, fields.function)):
def write(self, cr, uid, ids, data, *args, **argv): res = super(decimal_precision, self).write(cr, uid, ids, data, *args, **argv) for obj in self.pool.obj_list(): for colname,col in self.pool.get(obj)._columns.items(): if isinstance(col, fields.float): col.digits_change(cr) self.precision_get.clear_cache(cr.dbname) return res
self.precision_get.clear_cache(cr.dbname)
def write(self, cr, uid, ids, data, *args, **argv): res = super(decimal_precision, self).write(cr, uid, ids, data, *args, **argv) for obj in self.pool.obj_list(): for colname,col in self.pool.get(obj)._columns.items(): if isinstance(col, fields.float): col.digits_change(cr) self.precision_get.clear_cache(cr.dbname) return res
wf_service = netsvc.LocalService("workflow")
def default_get(self, cr, uid, fields, context): """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary which of fields with values. """ res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context) active_id = context and context.get('active_id',False) if active_id: j_obj = self.pool.get('account.journal') cr.execute("""select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id"""%(uid)) j_ids = map(lambda x1: x1[0], cr.fetchall()) journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)])
raise osv.except_osv('Error!','No order lines defined for this sale ')
raise osv.except_osv(_('Error!'),_('No order lines defined for this sale '))
def view_init(self, cr, uid, fields_list, context=None): res = super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context) active_id = context and context.get('active_id', False) or False if active_id: order = self.pool.get('pos.order').browse(cr, uid, active_id) if not order.lines: raise osv.except_osv('Error!','No order lines defined for this sale ') return True
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'resource.resource', c)
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'resource.resource', context=context)
def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True): resource_cal_leaves = self.pool.get('resource.calendar.leaves') dt_leave = [] if not id: return [(dt_from,dt_from + mx.DateTime.RelativeDateTime(hours=int(hours)*3))] resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)]) res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to']) for leave in res_leaves: dtf = mx.DateTime.strptime(leave['date_from'], '%Y-%m-%d %H:%M:%S') dtt = mx.DateTime.strptime(leave['date_to'], '%Y-%m-%d %H:%M:%S') no = dtt - dtf [dt_leave.append((dtf + mx.DateTime.RelativeDateTime(days=x)).strftime('%Y-%m-%d')) for x in range(int(no.days + 1))] dt_leave.sort() todo = hours cycle = 0 result = [] maxrecur = 100 current_hour = dt_from.hour while (todo>0) and maxrecur: cr.execute("select hour_from,hour_to from resource_calendar_week where dayofweek='%s' and calendar_id=%s order by hour_from", (dt_from.day_of_week,id)) for (hour_from,hour_to) in cr.fetchall(): leave_flag = False if (hour_to>current_hour) and (todo>0): m = max(hour_from, current_hour) if (hour_to-m)>todo: hour_to = m+todo dt_check = dt_from.strftime('%Y-%m-%d') for leave in dt_leave: if dt_check == leave: dt_check = mx.DateTime.strptime(dt_check, "%Y-%m-%d") + mx.DateTime.RelativeDateTime(days=1) leave_flag = True if leave_flag: break else: d1 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(m)), int((m%1) * 60)) d2 = mx.DateTime.DateTime(dt_from.year, dt_from.month, dt_from.day, int(math.floor(hour_to)), int((hour_to%1) * 60)) result.append((d1, d2)) current_hour = hour_to todo -= (hour_to - m) dt_from += mx.DateTime.RelativeDateTime(days=1) current_hour = 0 maxrecur -= 1 return result
'amount':total
'amount':total, 'state':voucher.state
def open_voucher(self, dbcr, uid, ids, context={}): cr = 0.0 dr = 0.0 total = 0.0 new_line = []
def write(self, cr, uid, ids, vals, context={}): res = super(account_voucher, self).write(cr, uid, ids, vals, context) if not 'state' in vals.keys(): self.open_voucher(cr, uid, ids, context) return res
def open_voucher(self, dbcr, uid, ids, context={}): cr = 0.0 dr = 0.0 total = 0.0 new_line = []
self.open_voucher(cr, uid, ids, context)
def voucher_recheck(self, cr, uid, ids, context={}): self.open_voucher(cr, uid, ids, context) self.write(cr, uid, ids, {'state':'recheck'}, context) return True
qry += " WHERE recurrent_id=%s" cr.execute(qry, (rdate,))
qry += " where recurrent_id='%s'" % (rdate) cr.execute(qry)
def uid2openobjectid(cr, uidval, oomodel, rdate): """ UID To Open Object Id @param cr: the current row, from the database cursor, @param uidval: Get USerId vale @oomodel: Open Object ModelName @param rdate: Get Recurrent Date """ __rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$') if not uidval: return (False, None) 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" cr.execute(qry, (rdate,)) 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, None)
_order = 'code,name'
_order = 'code'
def copy(self, cr, uid, id, default=None, context=None): if default is None: default = {} default = default.copy() default.update({'line_ids': []}) return super(account_tax_code, self).copy(cr, uid, id, default, context)
if prodlot_id: move_obj.write(cr, uid, [move.id],{'prodlot_id': prodlot_id,})
def do_partial(self, cr, uid, ids, partial_datas, context=None): """ Makes partial picking and moves done. @param partial_datas : Dictionary containing details of partial picking like partner_id, address_id, delivery_date, delivery moves with product_id, product_qty, uom @return: Dictionary of values """ if context is None: context = {} else: context = dict(context) res = {} move_obj = self.pool.get('stock.move') product_obj = self.pool.get('product.product') currency_obj = self.pool.get('res.currency') users_obj = self.pool.get('res.users') uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') sequence_obj = self.pool.get('ir.sequence') wf_service = netsvc.LocalService("workflow") partner_id = partial_datas.get('partner_id', False) address_id = partial_datas.get('address_id', False) delivery_date = partial_datas.get('delivery_date', False) for pick in self.browse(cr, uid, ids, context=context): new_picking = None new_moves = [] complete, too_many, too_few = [], [], [] move_product_qty = {} for move in pick.move_lines: if move.state in ('done', 'cancel'): continue partial_data = partial_datas.get('move%s'%(move.id), False) assert partial_data, _('Do not Found Partial data of Stock Move Line :%s' %(move.id)) product_qty = partial_data.get('product_qty',0.0) move_product_qty[move.id] = product_qty product_uom = partial_data.get('product_uom',False) product_price = partial_data.get('product_price',0.0) product_currency = partial_data.get('product_currency',False) prodlot_id = partial_data.get('prodlot_id',False) if prodlot_id: move_obj.write(cr, uid, [move.id],{'prodlot_id': prodlot_id,}) if move.product_qty == product_qty: complete.append(move) elif move.product_qty > product_qty: too_few.append(move) else: too_many.append(move)
self.write(cr, uid, ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
prodlot_id = partial_datas.get('move%s_prodlot_id'%(move.id), False) if prodlot_id: self.write(cr, uid, [move.id], {'prodlot_id': prodlot_id}) self.write(cr, uid, ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')})
def action_done(self, cr, uid, ids, context=None): """ Makes the move done and if all moves are done, it will finish the picking. @return: """ track_flag = False picking_ids = [] product_uom_obj = self.pool.get('product.uom') price_type_obj = self.pool.get('product.price.type') product_obj = self.pool.get('product.product') if context is None: context = {} 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)', (move.id, move.move_dest_id.id)) if move.move_dest_id.state in ('waiting', 'confirmed'): self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) if move.move_dest_id.picking_id: wf_service = netsvc.LocalService("workflow") wf_service.trg_write(uid, 'stock.picking', move.move_dest_id.picking_id.id, cr) else: pass if move.move_dest_id.auto_validate: self.action_done(cr, uid, [move.move_dest_id.id], context=context)
self.date_lst = []
def __init__(self, cr, uid, name, context=None): if context is None: context = {} super(partner_balance, self).__init__(cr, uid, name, context=context) self.date_lst = [] self.account_ids = [] self.localcontext.update( { 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'sum_litige': self._sum_litige, 'sum_sdebit': self._sum_sdebit, 'sum_scredit': self._sum_scredit, 'solde_debit': self._solde_balance_debit, 'solde_credit': self._solde_balance_credit, 'get_currency': self._get_currency, 'comma_me' : self.comma_me, 'get_fiscalyear': self._get_fiscalyear, 'get_periods':self.get_periods, 'get_journal': self._get_journal, 'get_filter': self._get_filter, 'get_account': self._get_account, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, 'get_partners':self._get_partners, }) ## Compute account list one time
result = '' if form.has_key('periods') and form['periods']: period_ids = form['periods'] per_ids = self.pool.get('account.period').browse(self.cr, self.uid, form['periods']) for r in per_ids: if r == per_ids[len(per_ids)-1]: result+=r.name+". " else: result+=r.name+", " else: fy_obj = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) res = fy_obj.period_ids len_res = len(res) for r in res: if r == res[len_res-1]: result += r.name + ". " else: result += r.name + ", " return str(result and result[:-1]) or 'ALL' def date_range(self, start, end): if not start or not end: return [] start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d"))) end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d"))) full_str_date = [] r = (end+datetime.timedelta(days=1)-start).days date_array = [start+datetime.timedelta(days=i) for i in range(r)] for date in date_array: full_str_date.append(str(date)) return full_str_date def transform_period_into_date_array(self, data): if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
result = '' if form.has_key('periods') and form['periods']: period_ids = form['periods'] per_ids = self.pool.get('account.period').browse(self.cr, self.uid, form['periods']) for r in per_ids: if r == per_ids[len(per_ids)-1]: result+=r.name+". " else: result+=r.name+", "
def get_periods(self, form): result = '' if form.has_key('periods') and form['periods']: period_ids = form['periods'] per_ids = self.pool.get('account.period').browse(self.cr, self.uid, form['periods']) for r in per_ids: if r == per_ids[len(per_ids)-1]: result+=r.name+". " else: result+=r.name+", " else: fy_obj = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) res = fy_obj.period_ids len_res = len(res) for r in res: if r == res[len_res-1]: result += r.name + ". " else: result += r.name + ", " return str(result and result[:-1]) or 'ALL'
periods_id = data['form']['periods'] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort() def transform_date_into_date_array(self, data): return_array = self.date_range(data['form']['date_from'], data['form']['date_to']) self.date_lst = return_array self.date_lst.sort() def transform_none_into_date_array(self, data): sql = "SELECT min(date) as start_date from account_move_line" self.cr.execute(sql) start_date = self.cr.fetchone()[0] sql = "SELECT max(date) as start_date from account_move_line" self.cr.execute(sql) stop_date = self.cr.fetchone()[0] array = [] array = array + self.date_range(start_date, stop_date) self.date_lst = array self.date_lst.sort()
fy_obj = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) res = fy_obj.period_ids len_res = len(res) for r in res: if r == res[len_res-1]: result += r.name + ". " else: result += r.name + ", " return str(result and result[:-1]) or 'ALL'
def transform_period_into_date_array(self, data): ## Get All Period Date # # If we have no period we will take all perdio in the FiscalYear. if not data['form']['periods']: periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) else: periods_id = data['form']['periods'] date_array = [] for period_id in periods_id: period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id) date_array = date_array + self.date_range(period_obj.date_start, period_obj.date_stop) self.date_lst = date_array self.date_lst.sort()
if data['form']['filter'] == 'filter_no': self.transform_none_into_date_array(data) elif data['form']['filter'] == 'filter_date': self.transform_date_into_date_array(data) elif data['form']['filter'] == 'filter_period': self.transform_period_into_date_array(data)
def set_context(self, objects, data, ids, report_type=None): # Transformation des date # # if data['form']['filter'] == 'filter_no': self.transform_none_into_date_array(data) elif data['form']['filter'] == 'filter_date': self.transform_date_into_date_array(data) elif data['form']['filter'] == 'filter_period': self.transform_period_into_date_array(data)
result_tmp = 0.0
def _sum_debit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst))) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
if self.date_lst: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst))) temp_res = float(self.cr.fetchone()[0] or 0.0)
self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND " + self.query + "" , (tuple(self.account_ids), )) temp_res = float(self.cr.fetchone()[0] or 0.0)
def _sum_debit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst))) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
result_tmp = result_tmp + temp_res return result_tmp
return temp_res
def _sum_debit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst))) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
result_tmp = 0.0
def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids),)) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
if self.date_lst: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0)
self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND " + self.query + "" , (tuple(self.account_ids),)) temp_res = float(self.cr.fetchone()[0] or 0.0)
def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids),)) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
result_tmp = result_tmp + temp_res return result_tmp
return temp_res
def _sum_credit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids),)) temp_res += float(self.cr.fetchone()[0] or 0.0) result_tmp = result_tmp + temp_res return result_tmp
result_tmp = 0.0
def _sum_litige(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "AND l.blocked=TRUE ", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0)
if self.date_lst:
self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND " + self.query + " " \ "AND l.blocked=TRUE ", (tuple(self.account_ids), )) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance:
def _sum_litige(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "AND l.blocked=TRUE ", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0)
"WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "AND l.blocked=TRUE ", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0) return result_tmp + temp_res
"WHERE l.account_id IN %s " \ "AND l.blocked=TRUE "\ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0) return temp_res
def _sum_litige(self, data): if not self.ids: return 0.0 result_tmp = 0.0 temp_res = 0.0 if self.date_lst: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "AND l.blocked=TRUE ", (tuple(self.account_ids), tuple(self.date_lst),)) temp_res = float(self.cr.fetchone()[0] or 0.0) if self.initial_balance: self.cr.execute( "SELECT sum(debit-credit) " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s " \ "AND " + self.init_query + "" , (tuple(self.account_ids), )) temp_res += float(self.cr.fetchone()[0] or 0.0)
if self.date_lst: self.cr.execute( "SELECT CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "GROUP BY l.partner_id", (tuple(self.account_ids), tuple(self.date_lst),)) a = self.cr.fetchone()[0] if self.cr.fetchone() != None: result_tmp = result_tmp + (a or 0.0) else: result_tmp = 0.0
self.cr.execute( "SELECT CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND " + self.query + " " \ "GROUP BY l.partner_id", (tuple(self.account_ids),)) a = self.cr.fetchone()[0] if self.cr.fetchone() != None: result_tmp = result_tmp + (a or 0.0) else: result_tmp = 0.0
def _sum_sdebit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 a = 0.0 if self.date_lst: self.cr.execute( "SELECT CASE WHEN sum(debit) > sum(credit) " \ "THEN sum(debit) - sum(credit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "GROUP BY l.partner_id", (tuple(self.account_ids), tuple(self.date_lst),)) a = self.cr.fetchone()[0]
if self.date_lst: self.cr.execute( "SELECT CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "GROUP BY l.partner_id", (tuple(self.account_ids), tuple(self.date_lst),)) a = self.cr.fetchone()[0] or 0.0 if self.cr.fetchone() != None: result_tmp = result_tmp + (a or 0.0) else: result_tmp = 0.0
self.cr.execute( "SELECT CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND " + self.query + " " \ "GROUP BY l.partner_id", (tuple(self.account_ids), )) a = self.cr.fetchone()[0] or 0.0 if self.cr.fetchone() != None: result_tmp = result_tmp + (a or 0.0) else: result_tmp = 0.0
def _sum_scredit(self, data): if not self.ids: return 0.0 result_tmp = 0.0 a = 0.0 if self.date_lst: self.cr.execute( "SELECT CASE WHEN sum(debit) < sum(credit) " \ "THEN sum(credit) - sum(debit) " \ "ELSE 0 " \ "END " \ "FROM account_move_line AS l " \ "WHERE l.account_id IN %s" \ "AND l.date IN %s " \ "GROUP BY l.partner_id", (tuple(self.account_ids), tuple(self.date_lst),)) a = self.cr.fetchone()[0] or 0.0 if self.cr.fetchone() != None: result_tmp = result_tmp + (a or 0.0)
result['name'] += ':' + self.pool.get('account.period').read(cr, uid, [data['period_id']], context=context)[0]['code']
period_code = period_obj.read(cr, uid, [data['period_id']], context=context)[0]['code'] result['name'] += period_code and (':' + period_code) or ''
def account_tax_chart_open_window(self, cr, uid, ids, context=None): """ Opens chart of Accounts @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of account chart’s IDs @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries """ mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') period_obj = self.pool.get('account.period') if context is None: context = {} data = self.read(cr, uid, ids, [], context=context)[0] result = mod_obj._get_id(cr, uid, 'account', 'action_tax_code_tree') id = mod_obj.read(cr, uid, [result], ['res_id'], context=context)[0]['res_id'] result = act_obj.read(cr, uid, [id], context=context)[0] if data['period_id']: fiscalyear_id = period_obj.read(cr, uid, [data['period_id']], context=context)[0]['fiscalyear_id'][0] result['context'] = str({'period_id': data['period_id'], \ 'fiscalyear_id': fiscalyear_id, \ 'state': data['target_move']}) else: result['context'] = str({'state': data['target_move']})
res['value'].update({'purchase_price': purchase_price})
res['value'].update({'purchase_price': purchase_price * rate})
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) if product: purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price res['value'].update({'purchase_price': purchase_price}) return res
for record in self.browse(cr, uid, ids): if record.state=='validate': holiday_id=self.pool.get('hr.holidays.per.user').search(cr, uid, [('employee_id','=', record.employee_id.id),('holiday_status','=',record.holiday_status.id)]) if holiday_id: obj_holidays_per_user=self.pool.get('hr.holidays.per.user').browse(cr, uid,holiday_id[0]) self.pool.get('hr.holidays.per.user').write(cr,uid,obj_holidays_per_user.id,{'leaves_taken':obj_holidays_per_user.leaves_taken - record.number_of_days}) if record.case_id: if record.case_id.state <> 'draft': raise osv.except_osv(_('Warning !'), _('You can not cancel this holiday request. first You have to make its case in draft state.')) else: self.pool.get('crm.case').unlink(cr,uid,[record.case_id.id])
self._update_user_holidays(cr, uid, ids)
def holidays_cancel(self, cr, uid, ids, *args): for record in self.browse(cr, uid, ids): if record.state=='validate': holiday_id=self.pool.get('hr.holidays.per.user').search(cr, uid, [('employee_id','=', record.employee_id.id),('holiday_status','=',record.holiday_status.id)]) if holiday_id: obj_holidays_per_user=self.pool.get('hr.holidays.per.user').browse(cr, uid,holiday_id[0]) self.pool.get('hr.holidays.per.user').write(cr,uid,obj_holidays_per_user.id,{'leaves_taken':obj_holidays_per_user.leaves_taken - record.number_of_days}) if record.case_id: if record.case_id.state <> 'draft': raise osv.except_osv(_('Warning !'), _('You can not cancel this holiday request. first You have to make its case in draft state.')) else: self.pool.get('crm.case').unlink(cr,uid,[record.case_id.id]) self.write(cr, uid, ids, { 'state':'cancel' }) self._create_holiday(cr, uid, ids) return True
return COLLECTION
if uri2 and len(uri2) < 2: return uri2[-1] return ''
def _get_dav_displayname(self,uri): self.parent.log_message('get DN: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri) if not dbname: if cr: cr.close() return COLLECTION node = self.uri2object(cr, uid, pool, uri2) if not node: if cr: cr.close() raise DAV_NotFound2(uri2) cr.close() return node.displayname
""" @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks,
"""Makes Database ready for query browsing @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks,
def action_dbready(self, cr, uid, ids, context = {}):
""" @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks,
"""Makes schema as done @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks,
def action_done(self, cr, uid, ids, context = {}):
"""
"""Handles MDX request
def request(self, cr, uid, name, request, context = {}):
if make_ids:
if make_ids and cube_obj.table_id.line_ids:
def search(self, cr, uid, args, offset = 0, limit = None, order = None, context = None, count = False):
tasks = self.browse( cr, uid, ids[0])
task_id = ids if isinstance(ids, list): task_id = ids[0] tasks = self.browse(cr, uid, task_id, context=context)
def write(self, cr, uid, ids, vals, context=None):
'price':i_line.product_id.product_tmpl_id.standard_price * i_line.quantity,
'price':get_price(cr, uid, inv, company_currency, i_line),
def move_line_get(self, cr, uid, invoice_id, context=None): res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context) inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) if inv.type in ('out_invoice','out_refund'): for i_line in inv.invoice_line: if i_line.product_id: if inv.type == 'out_invoice': # debit account dacc will be the output account # first check the product, if empty check the category dacc = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id if not dacc: dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id else: # = out_refund # debit account dacc will be the input account # first check the product, if empty check the category dacc = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id if not dacc: dacc = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id # in both cases the credit account cacc will be the expense account # first check the product, if empty check the category cacc = i_line.product_id.product_tmpl_id.property_account_expense and i_line.product_id.product_tmpl_id.property_account_expense.id if not cacc: cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id if dacc and cacc: res.append({ 'type':'src', 'name': i_line.name[:64], 'price_unit':i_line.product_id.product_tmpl_id.standard_price, 'quantity':i_line.quantity, 'price':i_line.product_id.product_tmpl_id.standard_price * i_line.quantity, 'account_id':dacc, 'product_id':i_line.product_id.id, 'uos_id':i_line.uos_id.id, 'account_analytic_id':i_line.account_analytic_id.id, 'taxes':i_line.invoice_line_tax_id, }) res.append({ 'type':'src', 'name': i_line.name[:64], 'price_unit':i_line.product_id.product_tmpl_id.standard_price, 'quantity':i_line.quantity, 'price': -1 * i_line.product_id.product_tmpl_id.standard_price * i_line.quantity, 'account_id':cacc, 'product_id':i_line.product_id.id, 'uos_id':i_line.uos_id.id, 'account_analytic_id':i_line.account_analytic_id.id, 'taxes':i_line.invoice_line_tax_id, }) elif inv.type in ('in_invoice','in_refund'): for i_line in inv.invoice_line: if i_line.product_id: if i_line.product_id.product_tmpl_id.type != 'service': # get the price difference account at the product acc = i_line.product_id.product_tmpl_id.property_account_creditor_price_difference and i_line.product_id.product_tmpl_id.property_account_creditor_price_difference.id if not acc: # if not found on the product get the price difference account at the category acc = i_line.product_id.categ_id.property_account_creditor_price_difference_categ and i_line.product_id.categ_id.property_account_creditor_price_difference_categ.id a = None if inv.type == 'in_invoice': # oa will be the stock input account # first check the product, if empty check the category oa = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id if not oa: oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id else: # = in_refund # oa will be the stock output account # first check the product, if empty check the category oa = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id if not oa: oa = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id if oa: # get the fiscal position fpos = i_line.invoice_id.fiscal_position or False a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) diff_res = [] # calculate and write down the possible price difference between invoice price and product price for line in res: if a == line['account_id'] and i_line.product_id.id == line['product_id']: uom = i_line.product_id.uos_id or i_line.product_id.uom_id standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.product_tmpl_id.standard_price, i_line.uos_id.id) if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: price_diff = i_line.price_unit - standard_price line.update({'price':standard_price * line['quantity']}) diff_res.append({ 'type':'src', 'name': i_line.name[:64], 'price_unit':price_diff, 'quantity':line['quantity'], 'price': price_diff * line['quantity'], 'account_id':acc, 'product_id':line['product_id'], 'uos_id':line['uos_id'], 'account_analytic_id':line['account_analytic_id'], 'taxes':line.get('taxes',[]), }) res += diff_res return res
'price': -1 * i_line.product_id.product_tmpl_id.standard_price * i_line.quantity,
'price': -1 * get_price(cr, uid, inv, company_currency, i_line),
def move_line_get(self, cr, uid, invoice_id, context=None): res = super(account_invoice_line,self).move_line_get(cr, uid, invoice_id, context=context) inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context) if inv.type in ('out_invoice','out_refund'): for i_line in inv.invoice_line: if i_line.product_id: if inv.type == 'out_invoice': # debit account dacc will be the output account # first check the product, if empty check the category dacc = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id if not dacc: dacc = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id else: # = out_refund # debit account dacc will be the input account # first check the product, if empty check the category dacc = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id if not dacc: dacc = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id # in both cases the credit account cacc will be the expense account # first check the product, if empty check the category cacc = i_line.product_id.product_tmpl_id.property_account_expense and i_line.product_id.product_tmpl_id.property_account_expense.id if not cacc: cacc = i_line.product_id.categ_id.property_account_expense_categ and i_line.product_id.categ_id.property_account_expense_categ.id if dacc and cacc: res.append({ 'type':'src', 'name': i_line.name[:64], 'price_unit':i_line.product_id.product_tmpl_id.standard_price, 'quantity':i_line.quantity, 'price':i_line.product_id.product_tmpl_id.standard_price * i_line.quantity, 'account_id':dacc, 'product_id':i_line.product_id.id, 'uos_id':i_line.uos_id.id, 'account_analytic_id':i_line.account_analytic_id.id, 'taxes':i_line.invoice_line_tax_id, }) res.append({ 'type':'src', 'name': i_line.name[:64], 'price_unit':i_line.product_id.product_tmpl_id.standard_price, 'quantity':i_line.quantity, 'price': -1 * i_line.product_id.product_tmpl_id.standard_price * i_line.quantity, 'account_id':cacc, 'product_id':i_line.product_id.id, 'uos_id':i_line.uos_id.id, 'account_analytic_id':i_line.account_analytic_id.id, 'taxes':i_line.invoice_line_tax_id, }) elif inv.type in ('in_invoice','in_refund'): for i_line in inv.invoice_line: if i_line.product_id: if i_line.product_id.product_tmpl_id.type != 'service': # get the price difference account at the product acc = i_line.product_id.product_tmpl_id.property_account_creditor_price_difference and i_line.product_id.product_tmpl_id.property_account_creditor_price_difference.id if not acc: # if not found on the product get the price difference account at the category acc = i_line.product_id.categ_id.property_account_creditor_price_difference_categ and i_line.product_id.categ_id.property_account_creditor_price_difference_categ.id a = None if inv.type == 'in_invoice': # oa will be the stock input account # first check the product, if empty check the category oa = i_line.product_id.product_tmpl_id.property_stock_account_input and i_line.product_id.product_tmpl_id.property_stock_account_input.id if not oa: oa = i_line.product_id.categ_id.property_stock_account_input_categ and i_line.product_id.categ_id.property_stock_account_input_categ.id else: # = in_refund # oa will be the stock output account # first check the product, if empty check the category oa = i_line.product_id.product_tmpl_id.property_stock_account_output and i_line.product_id.product_tmpl_id.property_stock_account_output.id if not oa: oa = i_line.product_id.categ_id.property_stock_account_output_categ and i_line.product_id.categ_id.property_stock_account_output_categ.id if oa: # get the fiscal position fpos = i_line.invoice_id.fiscal_position or False a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) diff_res = [] # calculate and write down the possible price difference between invoice price and product price for line in res: if a == line['account_id'] and i_line.product_id.id == line['product_id']: uom = i_line.product_id.uos_id or i_line.product_id.uom_id standard_price = self.pool.get('product.uom')._compute_price(cr, uid, uom.id, i_line.product_id.product_tmpl_id.standard_price, i_line.uos_id.id) if standard_price != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc: price_diff = i_line.price_unit - standard_price line.update({'price':standard_price * line['quantity']}) diff_res.append({ 'type':'src', 'name': i_line.name[:64], 'price_unit':price_diff, 'quantity':line['quantity'], 'price': price_diff * line['quantity'], 'account_id':acc, 'product_id':line['product_id'], 'uos_id':line['uos_id'], 'account_analytic_id':line['account_analytic_id'], 'taxes':line.get('taxes',[]), }) res += diff_res return res
(SELECT count(id) FROM mailgate_message WHERE model='crm.helpdesk' AND res_id=c.id AND history=True) AS email,
(SELECT count(id) FROM mailgate_message WHERE model='crm.claim' AND res_id=c.id AND history=True) AS email, (SELECT avg(probability) FROM crm_case_stage WHERE type='claim' AND id=c.stage_id) AS probability,
def init(self, cr):
if not new_journal.centralisation:
if (not new_journal.centralisation) or new_journal.entry_posted:
def data_save(self, cr, uid, ids, context=None): """ This function close account fiscalyear and create entries in new fiscalyear @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Account fiscalyear close state’s IDs
_('The journal must have centralised counterpart'))
_('The journal must have centralised counterpart without the Skipping draft state option checked!'))
def data_save(self, cr, uid, ids, context=None): """ This function close account fiscalyear and create entries in new fiscalyear @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param ids: List of Account fiscalyear close state’s IDs
result['name'] = res.name
result['name'] = res.partner_ref
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): if context is None: context = {} 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 {'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id) fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
price_type.field)[prod_id], round=False)
price_type.field)[prod_id], round=False, context=context)
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), } ''' price=False item_id=0 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')
'order_id': fields.many2one('sale.order', 'Order Ref', required=True, ondelete='cascade', select=True), 'name': fields.char('Description', size=256, required=True, select=True),
'order_id': fields.many2one('sale.order', 'Order Ref', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}), 'name': fields.char('Description', size=256, required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer"),
'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order confirmation the the shipping of the products to the customer", readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'price_unit': fields.float('Unit Price', required=True, digits=(16, int(config['price_accuracy']))),
'price_unit': fields.float('Unit Price', required=True, digits=(16, int(config['price_accuracy'])), readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes'), 'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procure Method', required=True), 'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties'),
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft':[('readonly',False)]}), 'type': fields.selection([('make_to_stock', 'from stock'), ('make_to_order', 'on order')], 'Procure Method', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'property_ids': fields.many2many('mrp.property', 'sale_order_line_property_rel', 'order_id', 'property_id', 'Properties', readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16, 2), required=True), 'product_uom': fields.many2one('product.uom', 'Product UoM', required=True), 'product_uos_qty': fields.float('Quantity (UoS)'),
'product_uom_qty': fields.float('Quantity (UoM)', digits=(16, 2), required=True, readonly=True, states={'draft':[('readonly',False)]}), 'product_uom': fields.many2one('product.uom', 'Product UoM', required=True, readonly=True, states={'draft':[('readonly',False)]}), 'product_uos_qty': fields.float('Quantity (UoS)', readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'discount': fields.float('Discount (%)', digits=(16, 2)),
'discount': fields.float('Discount (%)', digits=(16, 2), readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'th_weight': fields.float('Weight'),
'th_weight': fields.float('Weight', readonly=True, states={'draft':[('readonly',False)]}),
def _number_packages(self, cr, uid, ids, field_name, arg, context): res = {} for line in self.browse(cr, uid, ids): try: res[line.id] = int(line.product_uom_qty / line.product_packaging.qty) except: res[line.id] = 1 return res
'move_created_ids': [], 'state': 'draft'
'move_lines2' : [], 'move_created_ids' : [], 'move_created_ids2' : [], 'product_lines' : [], 'state': 'draft', 'picking_id': False
def copy(self, cr, uid, id, default=None,context=None): if not default: default = {} default.update({ 'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.production'), 'move_lines' : [], 'move_created_ids': [], 'state': 'draft' }) return super(mrp_production, self).copy(cr, uid, id, default, context)
where.append((self.namefield,'=',name))
where.append((self.namefield,'=like',name.replace('\\','\\\\')))
def _child_get(self, cr, name = None, domain=None): """ return virtual children of resource, based on the foreign object.
name = getattr(bo, self.namefield) if not name:
res_name = getattr(bo, self.namefield) if not res_name:
def _child_get(self, cr, name = None, domain=None): """ return virtual children of resource, based on the foreign object.
res.append(self.res_obj_class(name, self.dir_id, self, self.context, self.res_model, bo))
res_name = res_name.replace('/','_') if name and (res_name != name): continue res.append(self.res_obj_class(res_name, self.dir_id, self, self.context, self.res_model, bo))
def _child_get(self, cr, name = None, domain=None): """ return virtual children of resource, based on the foreign object.
where1 = where + [(obj._parent_name, '=', self.res_id)]
where1.append((obj._parent_name, '=', self.res_id))
def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj
stock_picking_make('stock.picking.make')
def default_get(self, cursor, user, fields, context): """ To get default values for the object. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary which of fields with values. """ res = super(stock_picking_make, self).default_get(cursor, user, fields, context=context) record_ids = context and context.get('active_ids',False) or False if record_ids: picking_obj = self.pool.get('stock.picking') picking_ids = picking_obj.search(cursor, user, [ ('id', 'in', record_ids), ('state', '<>', 'done'), ('state', '<>', 'cancel')], context=context) res['picking_ids'] = picking_ids return res def make_packing(self, cursor, user, ids, context): """ Make Picking. @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param fields: List of fields for which we want default values @param context: A standard dictionary @return: A dictionary which of fields with values. """ record_ids = context and context.get('active_ids',False) or False wkf_service = netsvc.LocalService('workflow') picking_obj = self.pool.get('stock.picking') data = self.read(cursor, user, ids[0]) pick_ids = data['picking_ids'] picking_obj.force_assign(cursor, user, pick_ids) picking_obj.action_move(cursor, user, pick_ids) for picking_id in ids: wkf_service.trg_validate(user, 'stock.picking', picking_id, 'button_done', cursor) return {} stock_picking_make()
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 = data['form']['pickings'][0][2] print"-------ids--------",ids picking_obj.force_assign(cursor, user, ids) picking_obj.action_move(cursor, user, ids) for picking_id in ids: wkf_service.trg_validate(user, 'stock.picking', picking_id, 'button_done', cursor) return {}
vals_journal['type'] = 'cash'
vals_journal['type'] = 'bank'
def generate_configurable_chart(self, cr, uid, ids, context=None): obj_acc = self.pool.get('account.account') obj_acc_tax = self.pool.get('account.tax') obj_journal = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') obj_acc_template = self.pool.get('account.account.template') obj_fiscal_position_template = self.pool.get('account.fiscal.position.template') obj_fiscal_position = self.pool.get('account.fiscal.position') mod_obj = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal')
def format_body(self, body): return body and tools.ustr(body.encode('ascii', 'replace')) or ''
def format_body(self, body): return body and tools.ustr(body) or ''
def format_body(self, body): return body and tools.ustr(body.encode('ascii', 'replace')) or ''
"AND (s.user_id IN %s) " %(tuple(so_line), tuple(so), company, tuple(users)))
"AND (s.user_id IN %s) " ,(tuple(so_line), tuple(so), company, tuple(users)))
def _sales_per_users(self, cr, uid, so, so_line, company, users): 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) " \ "AND (s.user_id IN %s) " %(tuple(so_line), tuple(so), company, tuple(users))) ret = cr.fetchone()[0] or 0.0 return ret