rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
def onchange_uom(self, cr, uid, ids, product_uom, ): | def onchange_uom(self, cr, uid, ids, product_uom=False): ret = {} | def onchange_uom(self, cr, uid, ids, product_uom, ): if not product_uom: return {} ret={} val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.active_uom.id, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['planned_outgoing'] = rounding(coeff * val.planned_outgoing, round_value) ret['to_procure'] = rounding(coeff * val.to_procure, round_value) ret['active_uom'] = product_uom return {'value': ret} |
ret={} | if not ids: return {} | def onchange_uom(self, cr, uid, ids, product_uom, ): if not product_uom: return {} ret={} val1 = self.browse(cr, uid, ids) val = val1[0] coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.active_uom.id, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['planned_outgoing'] = rounding(coeff * val.planned_outgoing, round_value) ret['to_procure'] = rounding(coeff * val.to_procure, round_value) ret['active_uom'] = product_uom return {'value': ret} |
coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.active_uom.id, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['planned_outgoing'] = rounding(coeff * val.planned_outgoing, round_value) ret['to_procure'] = rounding(coeff * val.to_procure, round_value) | if val.active_uom: coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.active_uom.id, {}) coeff_def2uom, round_value = self._from_default_uom_factor( cr, uid, val, product_uom, {}) coeff = coeff_uom2def * coeff_def2uom ret['planned_outgoing'] = rounding(coeff * val.planned_outgoing, round_value) ret['to_procure'] = rounding(coeff * val.to_procure, round_value) | coeff_uom2def = self._to_default_uom_factor(cr, uid, val, val.active_uom.id, {}) |
def _to_default_uom_factor(self, cr, uid, val, uom_id, context): | def _to_default_uom_factor(self, cr, uid, val, uom_id, context=None): | def _to_default_uom_factor(self, cr, uid, val, uom_id, context): uom_obj = self.pool.get('product.uom') uom = uom_obj.browse(cr, uid, uom_id, context=context) coef = uom.factor if uom.category_id.id != val.product_id.uom_id.category_id.id: coef = coef / val.product_id.uos_coeff return val.product_id.uom_id.factor / coef |
def _from_default_uom_factor(self, cr, uid, val, uom_id, context): | def _from_default_uom_factor(self, cr, uid, val, uom_id, context=None): | def _from_default_uom_factor(self, cr, uid, val, uom_id, context): uom_obj = self.pool.get('product.uom') uom = uom_obj.browse(cr, uid, uom_id, context=context) res = uom.factor if uom.category_id.id != val.product_id.uom_id.category_id.id: res = res / val.product_id.uos_coeff return res / val.product_id.uom_id.factor, uom.rounding |
vals['partner_id'] = __get_partner_id(cr, uid, \ | vals['partner_id'] = self.__get_partner_id(cr, uid, \ | def create(self, cr, uid, vals, context=None): if not context: context = {} vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False) if not vals['parent_id']: vals['parent_id'] = self.pool.get('document.directory')._get_root_directory(cr,uid, context) if not vals.get('res_id', False) and context.get('default_res_id', False): vals['res_id'] = context.get('default_res_id', False) if not vals.get('res_model', False) and context.get('default_res_model', False): vals['res_model'] = context.get('default_res_model', False) if vals.get('res_id', False) and vals.get('res_model', False) \ and not vals.get('partner_id', False): vals['partner_id'] = __get_partner_id(cr, uid, \ vals['res_model'], vals['res_id'], context) |
if False: obj_model = self.pool.get(vals['res_model']) if obj_model._name == 'res.partner': return res_id elif 'partner_id' in obj_model._columns and obj_model._columns['partner_id']._obj == 'res.partner': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.partner_id.id elif 'address_id' in obj_model._columns and obj_model._columns['address_id']._obj == 'res.partner.address': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.address_id.partner_id.id | obj_model = self.pool.get(res_model) if obj_model._name == 'res.partner': return res_id elif 'partner_id' in obj_model._columns and obj_model._columns['partner_id']._obj == 'res.partner': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.partner_id.id elif 'address_id' in obj_model._columns and obj_model._columns['address_id']._obj == 'res.partner.address': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.address_id.partner_id.id | def __get_partner_id(self, cr, uid, res_model, res_id, context): """ A helper to retrieve the associated partner from any res_model+id It is a hack that will try to discover if the mentioned record is clearly associated with a partner record. """ if False: obj_model = self.pool.get(vals['res_model']) if obj_model._name == 'res.partner': return res_id elif 'partner_id' in obj_model._columns and obj_model._columns['partner_id']._obj == 'res.partner': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.partner_id.id elif 'address_id' in obj_model._columns and obj_model._columns['address_id']._obj == 'res.partner.address': bro = obj_model.browse(self, cr, uid, res_id, context=context) return bro.address_id.partner_id.id return False |
unit=False, context=None): | unit=False, journal_id=False, context=None): | def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, unit=False, context=None): if context==None: context={} uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') company_obj=self.pool.get('res.company') if prod_id: prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id if not a: a = prod.categ_id.property_account_expense_categ.id if not a: raise osv.except_osv(_('Error !'), _('There is no expense account defined ' \ 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) if not company_id: company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) |
flag = False | def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, unit=False, context=None): if context==None: context={} uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') company_obj=self.pool.get('res.company') if prod_id: prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id if not a: a = prod.categ_id.property_account_expense_categ.id if not a: raise osv.except_osv(_('Error !'), _('There is no expense account defined ' \ 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) if not company_id: company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) |
|
pricetype=self.pool.get('product.price.type').browse(cr, uid, company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) | pricetype=product_price_type_obj.browse(cr, uid, company_obj.browse(cr,uid,company_id).property_valuation_price_type.id) if journal_id: journal = analytic_journal_obj.browse(cr, uid, journal_id) if journal.type == 'sale': product_price_type_ids = product_price_type_obj.search(cr, uid, [('field','=','list_price')], context) if product_price_type_ids: pricetype = product_price_type_obj.browse(cr, uid, product_price_type_ids, context)[0] | def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, unit=False, context=None): if context==None: context={} uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') company_obj=self.pool.get('res.company') if prod_id: prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id if not a: a = prod.categ_id.property_account_expense_categ.id if not a: raise osv.except_osv(_('Error !'), _('There is no expense account defined ' \ 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) if not company_id: company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) |
'amount': - round(amount, prec), | 'amount': result, | def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount,company_id, unit=False, context=None): if context==None: context={} uom_obj = self.pool.get('product.uom') product_obj = self.pool.get('product.product') company_obj=self.pool.get('res.company') if prod_id: prod = product_obj.browse(cr, uid, prod_id) a = prod.product_tmpl_id.property_account_expense.id if not a: a = prod.categ_id.property_account_expense_categ.id if not a: raise osv.except_osv(_('Error !'), _('There is no expense account defined ' \ 'for this product: "%s" (id:%d)') % \ (prod.name, prod.id,)) if not company_id: company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) |
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): res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, context) | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context=context) | 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): res_prod = super(account_invoice_line,self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, context) rec = self.pool.get('account.analytic.default').account_get(cr, uid, product, partner_id, uid, time.strftime('%Y-%m-%d'), context) if rec and rec.analytics_id: res_prod['value'].update({'analytics_id':rec.analytics_id.id}) return res_prod |
company_id=company_obj._company_default_get(cr, uid, 'account.analytic.line', context) | company_id = company_obj._company_default_get(cr, uid, 'account.analytic.line', context=context) | def on_change_unit_amount(self, cr, uid, id, prod_id, quantity, company_id, unit=False, journal_id=False, context=None): if context==None: context={} if not journal_id: j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type','=','purchase')]) j_id = j_ids and j_ids[0] or False if not journal_id or not prod_id: return {} product_obj = self.pool.get('product.product') analytic_journal_obj =self.pool.get('account.analytic.journal') company_obj = self.pool.get('res.company') product_price_type_obj = self.pool.get('product.price.type') j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context) prod = product_obj.browse(cr, uid, prod_id) if not company_id: company_id = j_id.company_id.id result = 0.0 |
for meeting_id in ids: result[meeting_id] = {} if "attendees" in name: attendee_ids = attendee_obj.search(cr, uid, [('ref','=','%s,%d'%(self._name, meeting_id))]) result[meeting_id]["attendees"] = attendee_obj.export_cal(cr, uid, attendee_ids) if "alarms" in name: alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting_id)]) result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids) return result def _set_data(self, cr, uid, meeting_id, name, value, arg, context): if not value: return attendee_obj = self.pool.get('calendar.attendee') model_obj = self.pool.get('ir.model') alarm_obj = self.pool.get('calendar.alarm') eventdata = self.read(cr, uid, meeting_id, [name], context=context) if name == "attendees": attendee_ids = attendee_obj.import_cal(cr, uid, eventdata['attendees']) vals = { 'ref':'%s,%d'%('crm.meeting', meeting_id) } attendee_obj.write(cr, uid, attendee_ids, vals) if name == "alarms": model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] alarm_ids = alarm_obj.import_cal(cr, uid, eventdata['alarms']) vals = { 'res_id' : meeting.id, 'model_id' : model_id, } alarm_obj.write(cr, uid, alarm_ids, vals) alarm = alarm_obj.browse(cr, uid, alarm_ids)[0] self.write(cr, uid, [meeting_id], {'alarm_id':alarm.alarm_id}) return True _columns = { 'inherit_case_id': fields.many2one('crm.case', 'Case', ondelete='cascade'), 'class': fields.selection([('public', 'Public'), ('private', 'Private'), \ ('confidential', 'Confidential')], 'Privacy'), 'location': fields.char('Location', size=264, help="Gives Location of Meeting"), 'freebusy': fields.text('FreeBusy'), 'show_as': fields.selection([('free', 'Free'), \ ('busy', 'Busy')], 'show_as'), 'caldav_url': fields.char('Caldav URL', size=264), 'exdate': fields.text('Exception Date/Times', help="This property defines the list\ of date/time exceptions for arecurring calendar component."), 'exrule': fields.char('Exception Rule', size=352, help="defines a rule or repeating pattern\ for anexception to a recurrence set"), 'rrule': fields.char('Recurrent Rule', size=352, invisible="True"), 'rrule_type' : fields.selection([('none', 'None'), ('daily', 'Daily'), \ ('weekly', 'Weekly'), ('monthly', 'Monthly'), ('yearly', 'Yearly'), ('custom','Custom')], 'Recurrency'), 'attendees': fields.function(_get_data, method=True,\ fnct_inv=_set_data, string='Attendees', type="text", multi='attendees'), 'alarms': fields.function(_get_data, method=True,\ fnct_inv=_set_data, string='Attendees', type="text", multi='alarms'), 'alarm_id': fields.many2one('res.alarm', 'Alarm'), } _defaults = { 'class': lambda *a: 'public', 'show_as' : lambda *a : 'busy', } def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] | def _get_data(self, cr, uid, ids, name, arg, context): result = {} attendee_obj = self.pool.get('calendar.attendee') alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] for meeting_id in ids: result[meeting_id] = {} if "attendees" in name: attendee_ids = attendee_obj.search(cr, uid, [('ref','=','%s,%d'%(self._name, meeting_id))]) result[meeting_id]["attendees"] = attendee_obj.export_cal(cr, uid, attendee_ids) if "alarms" in name: alarm_ids = alarm_obj.search(cr, uid, [('model_id','=',model_id), ('res_id','=',meeting_id)]) result[meeting_id]["alarms"] = alarm_obj.export_cal(cr, uid, alarm_ids) return result |
|
attendee_ids = attendee_obj.search(cr, uid, [('ref','=','%s,%d'%(self._name, meeting.id))]) | def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] |
|
'attendee_ids': [(6,0, attendee_ids)], | 'attendee_ids': [(6,0, map(lambda x:x.id, meeting.attendee_ids))], | def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] |
'event_end_date' : meeting.date_deadline, | def do_alarm_create(self, cr, uid, ids, context={}): alarm_obj = self.pool.get('calendar.alarm') model_obj = self.pool.get('ir.model') attendee_obj = self.pool.get('calendar.attendee') model_id = model_obj.search(cr, uid, [('model','=',self._name)])[0] |
|
cr.execute("select m.id, m.rrule, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ | cr.execute("select m.id, m.rrule, m.date, m.exdate from crm_meeting m\ | 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, c.date, m.exdate from crm_meeting m\ join crm_case c on (c.id=m.inherit_case_id) \ where m.id in ("+ ','.join(map(lambda x: str(x), ids))+")") |
def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: if case.inherit_case_id: new_ids.append(case.inherit_case_id.id) res = getattr(self.pool.get('crm.case'), method)(cr, uid, new_ids, *args, **argv) if isinstance(ids, (str, int, long)) and isinstance(res, list): return res and res[0] or False return res def onchange_rrule_type(self, cr, uid, ids, type, *args, **argv): if type == 'none': return {'value': {'rrule': ''}} if type == 'custom': return {} rrule = self.pool.get('caldav.set.rrule') rrulestr = rrule.compute_rule_string(cr, uid, {'freq': type.upper(),\ 'interval': 1}) return {'value': {'rrule': rrulestr}} | def _map_ids(self, method, cr, uid, ids, *args, **argv): if isinstance(ids, (str, int, long)): select = [ids] else: select = ids case_data = self.browse(cr, uid, select) new_ids = [] for case in case_data: if case.inherit_case_id: new_ids.append(case.inherit_case_id.id) res = getattr(self.pool.get('crm.case'), method)(cr, uid, new_ids, *args, **argv) if isinstance(ids, (str, int, long)) and isinstance(res, list): return res and res[0] or False return res |
|
cr.execute("SELECT crm_case.user_id, 'busy' as status \ FROM crm_meeting meeting, crm_case \ WHERE meeting.inherit_case_id = crm_case.id \ and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s", | cr.execute("SELECT m.user_id, 'busy' as status \ FROM crm_meeting m\ where m.date <= %s and m.date_deadline >= %s \ and m.user_id = ANY(%s) and m.show_as = %s", | def _get_user_avail(self, cr, uid, ids, context=None): current_datetime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = super(res_users, self)._get_user_avail(cr, uid, ids, context) cr.execute("SELECT crm_case.user_id, 'busy' as status \ FROM crm_meeting meeting, crm_case \ WHERE meeting.inherit_case_id = crm_case.id \ and crm_case.date <= %s and crm_case.date_deadline >= %s and crm_case.user_id = ANY(%s) and meeting.show_as = %s", (current_datetime, current_datetime , ids, 'busy')) result = cr.dictfetchall() for user_data in result: user_id = user_data['user_id'] status = user_data['status'] res.update({user_id:status}) return res |
'picking_id': fields.many2one('stock.picking', 'Picking List', select=True,states={'done': [('readonly', True)]}), | 'picking_id': fields.many2one('stock.picking', 'Reference', select=True,states={'done': [('readonly', True)]}), | def _check_product_lot(self, cr, uid, ids): """ Checks whether move is done or not and production lot is assigned to that move. @return: True or False """ for move in self.browse(cr, uid, ids): if move.prodlot_id and move.state == 'done' and (move.prodlot_id.product_id.id != move.product_id.id): return False return True |
c.priority,c.type_action,c.date_deadline,c.date_closed | c.priority,c.type_action,c.date_deadline,c.date_closed,c.id | def init(self, cr): |
categ_ids = categ_obj.search(cr, uid, [('name','ilike','Part%')]) | categ_ids = categ_obj.search(cr, uid, [('object_id.model','=','crm.lead')]) | def make_opportunity(self, cr, uid, ids, context): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ |
'categ_id' : categ_ids[0], | 'categ_id' : categ_ids and categ_ids[0] or '', | def make_opportunity(self, cr, uid, ids, context): """ @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @param context: A standard dictionary for contextual values """ |
tax_ids = tax_obj.search(cr, uid, [('company_id', '=', company_id)]) | def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None): if context is None: context = {} company_id = context.get('company_id',False) tax_obj = self.pool.get('account.tax') if not partner_id: raise osv.except_osv(_('No Partner Defined !'),_("You must first select a partner !") ) if not product: if type in ('in_invoice', 'in_refund'): return {'value': {'categ_id': False}, 'domain':{'product_uom':[]}} else: return {'value': {'price_unit': 0.0, 'categ_id': False}, 'domain':{'product_uom':[]}} part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context) fpos_obj = self.pool.get('account.fiscal.position') fpos = fposition_id and fpos_obj.browse(cr, uid, fposition_id, context=context) or False |
|
sale_taxes_def = map(lambda x: x.id, res.taxes_id) sale_tax_ids = [tax for tax in tax_ids if tax in sale_taxes_def] sale_taxes = tax_obj.browse(cr, uid, sale_tax_ids) sale_taxes_all = sale_taxes and sale_taxes or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False) tax_id = fpos_obj.map_tax(cr, uid, fpos, sale_taxes_all) | taxes = res.taxes_id and res.taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a, context=context).tax_ids or False) | sale_taxes_def = map(lambda x: x.id, res.taxes_id) |
pur_taxes_def = map(lambda x: x.id, res.supplier_taxes_id) pur_tax_ids = [tax for tax in tax_ids if tax in pur_taxes_def] pur_taxes = tax_obj.browse(cr, uid, pur_tax_ids) pur_taxes_all = pur_taxes and pur_taxes or (a and self.pool.get('account.account').browse(cr, uid, a).tax_ids or False) tax_id = fpos_obj.map_tax(cr, uid, fpos, pur_taxes_all) | taxes = res.supplier_taxes_id and res.supplier_taxes_id or (a and self.pool.get('account.account').browse(cr, uid, a, context=context).tax_ids or False) tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes) | pur_taxes_def = map(lambda x: x.id, res.supplier_taxes_id) |
sum(l.product_qty*l.price_unit) as price_total, | l.price_unit*l.product_qty*u.factor as price_total, | def init(self, cr): tools.sql.drop_view_if_exists(cr, 'purchase_report') cr.execute(""" create or replace view purchase_report as ( select min(l.id) as id, s.date_order as date, to_char(s.date_order, 'YYYY') as name, to_char(s.date_order, 'MM') as month, to_char(s.date_order, 'YYYY-MM-DD') as day, s.state, s.date_approve, date_trunc('day',s.minimum_planned_date) as expected_date, s.partner_address_id, s.dest_address_id, s.pricelist_id, s.validator, s.warehouse_id as warehouse_id, s.partner_id as partner_id, s.fiscal_position, s.create_uid as user_id, s.company_id as company_id, s.invoice_method, s.shipped::integer as shipped_qty, l.invoiced::integer as invoiced_qty, l.product_id, s.location_id as location_id, sum(l.product_qty*u.factor) as quantity, extract(epoch from age(s.date_approve,s.date_order))/(24*60*60)::decimal(16,2) as delay, extract(epoch from age(s.minimum_planned_date,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass, count(*) as nbr, sum(l.product_qty*l.price_unit) as price_total, (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average from purchase_order s left join purchase_order_line l on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null group by s.company_id, s.create_uid, s.shipped, l.invoiced, s.partner_id, s.location_id, s.date_approve, s.minimum_planned_date, date_trunc('day',s.minimum_planned_date), s.partner_address_id, s.pricelist_id, s.validator, s.dest_address_id, l.product_id, s.date_order, to_char(s.date_order, 'YYYY'), to_char(s.date_order, 'MM'), to_char(s.date_order, 'YYYY-MM-DD'), s.state, s.warehouse_id, s.fiscal_position, s.invoice_method ) """) |
'type': fields.selection([('product','Stockable Product'),('rima','Rima'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help="Will change the way requisitions are processed. Consumables are stockable products with infinite stock, or for use when you have no inventory management in the system."), | 'type': fields.selection([('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True, help="Will change the way requisitions are processed. Consumables are stockable products with infinite stock, or for use when you have no inventory management in the system."), | def _calc_seller_delay(self, cr, uid, ids, name, arg, context={}): result = {} for product in self.browse(cr, uid, ids, context): if product.seller_ids: result[product.id] = product.seller_ids[0].delay else: result[product.id] = 1 return result |
new_id = cashmove_ref.createcr, uid, {'name': order.product.name+' order', | new_id = cashmove_ref.create(cr, uid, {'name': order.product.name+' order', | def confirm(self,cr,uid,ids,box,context): |
} | }) | def confirm(self,cr,uid,ids,box,context): |
self.pool.get('lunch.cashmove').unlink(cr, uid, [order.cashmove.id]) | if order.cashmove.id: self.pool.get('lunch.cashmove').unlink(cr, uid, [order.cashmove.id]) | def lunch_order_cancel(self, cr, uid, ids, context): |
self.write(cr, uid, [move.move_dest_id.id], {'state': 'assigned'}) | self.action_assign(cr, uid, [move.move_dest_id.id]) | 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: """ partial_datas='' picking_ids = [] move_ids = [] partial_obj=self.pool.get('stock.partial.picking') wf_service = netsvc.LocalService("workflow") partial_id=partial_obj.search(cr,uid,[]) if partial_id: partial_datas=partial_obj.read(cr,uid,partial_id)[0] if context is None: context = {} |
for case in self.browse(cr, uid, ids, context): if field_name != 'avg_answers': state = field_name[5:] cr.execute("select count(*) from crm_lead where \ section_id =%s and state='%s'"%(case.section_id.id, state)) state_cases = cr.fetchone()[0] perc_state = (state_cases / float(case.nbr)) * 100 res[case.id] = perc_state else: model_name = self._name.split('report.') if len(model_name) < 2: res[case.id] = 0.0 else: model_name = model_name[1] cr.execute("select count(*) from crm_case_log l, ir_model m \ where l.model_id=m.id and m.model = '%s'" , model_name) logs = cr.fetchone()[0] avg_ans = logs / case.nbr res[case.id] = avg_ans | def _get_data(self, cr, uid, ids, field_name, arg, context={}): |
|
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), 'day': fields.char('Day', size=128, readonly=True), | def _get_data(self, cr, uid, ids, field_name, arg, context={}): |
|
'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('section_id','=',section_id),('object_id.model', '=', 'hr.applicant')]"), | 'type_id': fields.many2one('crm.case.resource.type', 'Degree', domain="[('object_id.model', '=', 'hr.applicant')]"), | def _get_data(self, cr, uid, ids, field_name, arg, context={}): |
taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity) | taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id) | def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = {} tax_obj = self.pool.get('account.tax') cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids): price = line.price_unit * (1-(line.discount or 0.0)/100.0) taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity) res[line.id] = taxes['total'] if line.invoice_id: cur = line.invoice_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, res[line.id]) return res |
'project_id': procurement.project_id and procurement.project_id.id or False, | 'project_id': procurement.product_id.project_id and procurement.product_id.project_id.id or False, | def action_produce_assign_service(self, cr, uid, ids, context=None): if context is None: context = {} for procurement in self.browse(cr, uid, ids): self.write(cr, uid, [procurement.id], {'state': 'running'}) planned_hours = procurement.product_qty task_id = self.pool.get('project.task').create(cr, uid, { 'name': '%s:%s' % (procurement.origin or '', procurement.name), 'date_deadline': procurement.date_planned, 'planned_hours':planned_hours, 'remaining_hours': planned_hours, 'user_id': procurement.product_id.product_manager.id, 'notes': procurement.note, 'procurement_id': procurement.id, 'description': procurement.note, 'date_deadline': procurement.date_planned, 'project_id': procurement.project_id and procurement.project_id.id or False, 'state': 'draft', 'company_id': procurement.company_id.id, },context=context) self.write(cr, uid, [procurement.id],{'task_id':task_id}) return task_id |
res['fiscalyear'] = data['form']['fiscalyear_id'] | res['fiscalyear'] = data['form'].get('fiscalyear_id', False) | def set_context(self, objects, data, ids, report_type=None): new_ids = ids res = {} self.period_ids = [] period_obj = self.pool.get('account.period') res['periods'] = '' res['fiscalyear'] = data['form']['fiscalyear_id'] |
elif arg[0] == 'name': | def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False): job_ids = [] for arg in args: if arg[0] == 'address_id': self._order = 'sequence_partner' elif arg[0] == 'contact_id': self._order = 'sequence_contact' elif arg[0] == 'name': contact_obj = self.pool.get('res.partner.contact') search_arg = ['|', ('first_name', 'ilike', arg[2]), ('name', 'ilike', arg[2])] contact_ids = contact_obj.search(cr, user, search_arg, offset=offset, limit=limit, order=order, context=context, count=count) contacts = contact_obj.browse(cr, user, contact_ids, context=context) for contact in contacts: job_ids.extend([item.id for item in contact.job_ids]) |
|
cr.execute('SELECT emp.department_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id = emp.resource_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL', (user_id,)) | cr.execute('SELECT emp.department_id FROM hr_employee AS emp \ JOIN resource_resource AS res ON res.id = emp.resource_id \ JOIN hr_department as dept ON dept.id = emp.department_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL AND dept.manager_id IS NOT NULL', (user_id,)) | def _parent_compute(self, cr, uid, ids, name, args, context=None): if context is None: context = {} result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: emp_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', user_id)]) cr.execute('SELECT emp.department_id FROM hr_employee AS emp JOIN resource_resource AS res ON res.id = emp.resource_id \ WHERE res.user_id = %s AND emp.department_id IS NOT NULL', (user_id,)) ids_dept = [x[0] for x in cr.fetchall()] |
'incoterm': fields.selection(_incoterm_get, 'Incoterm', size=3, help="Incoterm which stands for 'International Commercial terms' implies its a series of sales terms which are used in the commercial transaction"), | 'incoterm': fields.many2one('stock.incoterms', 'Incoterm', help="Incoterm which stands for 'International Commercial terms' implies its a series of sales terms which are used in the commercial transaction"), | def _get_order(self, cr, uid, ids, context=None): if context is None: context = {} result = {} for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): result[line.order_id.id] = True return result.keys() |
interface.register_all(db) | self.pool.get('ir.actions.report.xml').register_all(cr = db.cursor()) | def upload_report(self, cr, uid, report_id, file_sxw, file_type, context): ''' Untested function ''' pool = pooler.get_pool(cr.dbname) sxwval = StringIO(base64.decodestring(file_sxw)) if file_type=='sxw': fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_oo2rml.xsl'),'rb') if file_type=='odt': fp = open(addons.get_module_resource('base_report_designer','openerp_sxw2rml', 'normalized_odt2rml.xsl'),'rb') report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], { 'report_sxw_content': base64.decodestring(file_sxw), 'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())), }) db = pooler.get_db_only(cr.dbname) interface.register_all(db) return True |
hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) | if uparts[0] and uparts[1]: hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) else: hurl = '%s%s' % (davpath, urllib.quote(fileloc)) | def _prop_elem_child(pnode, pns, v, pns_prefix): |
hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) | if uparts[0] and uparts[1]: hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) else: hurl = '%s%s' % (davpath, urllib.quote(fileloc)) | def mk_propname_response(self,uri,propnames,doc): """ make a new <prop> result element for a PROPNAME request This will simply format the propnames list. propnames should have the format {NS1 : [prop1, prop2, ...], NS2: ...} """ re=doc.createElement("D:response") # write href information uparts=urlparse.urlparse(uri) fileloc=uparts[2] if isinstance(fileloc, unicode): fileloc = fileloc.encode('utf-8') href=doc.createElement("D:href") davpath = self._dataclass.parent.get_davpath() hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) huri=doc.createTextNode(hurl) href.appendChild(huri) re.appendChild(href) ps=doc.createElement("D:propstat") nsnum=0 for ns,plist in propnames.items(): # write prop element pr=doc.createElement("D:prop") if ns == 'DAV': nsp = 'D' else: nsp="ns"+str(nsnum) ps.setAttribute("xmlns:"+nsp,ns) nsnum=nsnum+1 # write propertynames for p in plist: pe=doc.createElement(nsp+":"+p) pr.appendChild(pe) ps.appendChild(pr) re.appendChild(ps) return re |
amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.amount) | amount = currency_pool.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount) | def _get_payment_term_lines(term_id, amount): term_pool = self.pool.get('account.payment.term') if term_id and amount: terms = term_pool.compute(cr, uid, term_id, amount) return terms return False |
def _construct_constraint_msg(self, cr, uid, ids): | def _construct_constraint_msg(self, cr, uid, ids, context=None): | def _construct_constraint_msg(self, cr, uid, ids): def default_vat_check(cn, vn): # by default, a VAT number is valid if: # it starts with 2 letters # has more than 3 characters return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat) if default_vat_check(vat_country, vat_number): vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number' return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no) return _('The VAT is invalid, It should begin with the country code'), () |
if move.analytic_account_id: anal_val = {} amt = (val['credit'] or 0.0) - (val['debit'] or 0.0) anal_val = { 'name': val['name'], 'ref': val['ref'], 'date': val['date'], 'amount': amt, 'account_id': val['analytic_account_id'], 'currency_id': val['currency_id'], 'general_account_id': val['account_id'], 'journal_id': st.journal_id.analytic_journal_id.id, 'period_id': val['period_id'], 'user_id': uid, 'move_id': move_line_id } if val.get('amount_currency', False): anal_val['amount_currency'] = val['amount_currency'] account_analytic_line_obj.create(cr, uid, anal_val, context=context) | def button_confirm_cash(self, cr, uid, ids, context={}): |
|
if not turi.startswith('/'): uparts=urlparse.urlparse(turi) turi=uparts[2] | def get_childs(self, uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get childs: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True) |
|
self.parent.log_error("ignore href %s because it is not under request path", turi) | self.parent.log_error("ignore href %s because it is not under request path %s", turi, ul) | def get_childs(self, uri, filters=None): """ return the child objects as self.baseuris for the given URI """ self.parent.log_message('get childs: %s' % uri) cr, uid, pool, dbname, uri2 = self.get_cr(uri, allow_last=True) |
fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) period_query_cond=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear'])]) | fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear_id']) period_ids=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear_id'])]) | def _load(self, name, form): fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) period_query_cond=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear'])]) |
self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id IN %s", (tuple(period_query_cond),)) dates = self.cr.dictfetchall() self._set_variable('date_start', dates[0]['date_start']) self._set_variable('date_stop', dates[0]['date_stop']) | if period_ids: self.cr.execute("SELECT MIN(date_start) AS date_start, MAX(date_stop) AS date_stop FROM account_period WHERE id = ANY(%s)", (period_ids,)) dates = self.cr.dictfetchall() else: dates = False if dates: self._set_variable('date_start', dates[0]['date_start']) self._set_variable('date_stop', dates[0]['date_stop']) | def _load(self, name, form): fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) period_query_cond=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear'])]) |
self._load_accounts(form,line['code'],eval(line['definition']),fiscalyear,period_query_cond) | self._load_accounts(form,line['code'],eval(line['definition']),fiscalyear,period_ids) | def _load(self, name, form): fiscalyear = self.pool.get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear']) period_query_cond=self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id', '=', form['fiscalyear'])]) |
def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond): | def _load_accounts(self, form, code, definition, fiscalyear, period_ids): | def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond): accounts = {} for x in definition['load']: p = x.split(":") accounts[p[1]] = [p[0],p[2]] sum = 0.0 if fiscalyear.state != 'done' or not code.startswith('bpcheck'): query_cond = "(" for account in accounts: query_cond += "aa.code LIKE '" + account + "%' OR " query_cond = query_cond[:-4]+")" |
query_cond += "aa.code LIKE '" + account + "%' OR " | query_cond += "aa.code LIKE '" + account + "%%' OR " | def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond): accounts = {} for x in definition['load']: p = x.split(":") accounts[p[1]] = [p[0],p[2]] sum = 0.0 if fiscalyear.state != 'done' or not code.startswith('bpcheck'): query_cond = "(" for account in accounts: query_cond += "aa.code LIKE '" + account + "%' OR " query_cond = query_cond[:-4]+")" |
query_cond += "aa.code NOT LIKE '"+account+"%' AND " | query_cond += "aa.code NOT LIKE '"+account+"%%' AND " | def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond): accounts = {} for x in definition['load']: p = x.split(":") accounts[p[1]] = [p[0],p[2]] sum = 0.0 if fiscalyear.state != 'done' or not code.startswith('bpcheck'): query_cond = "(" for account in accounts: query_cond += "aa.code LIKE '" + account + "%' OR " query_cond = query_cond[:-4]+")" |
closed_cond=" AND (aml.move_id NOT IN (SELECT account_move.id as move_id FROM account_move WHERE period_id IN "+str(tuple(period_query_cond))+" AND journal_id=(SELECT res_id FROM ir_model_data WHERE name='closing_journal' AND module='l10n_fr')) OR (aa.type != 'income' AND aa.type !='expense'))" | closed_cond=" AND (aml.move_id NOT IN (SELECT account_move.id as move_id FROM account_move WHERE period_id = ANY(%s) AND journal_id=(SELECT res_id FROM ir_model_data WHERE name='closing_journal' AND module='l10n_fr')) OR (aa.type != 'income' AND aa.type !='expense'))" query_params.append(list(period_ids)) | def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond): accounts = {} for x in definition['load']: p = x.split(":") accounts[p[1]] = [p[0],p[2]] sum = 0.0 if fiscalyear.state != 'done' or not code.startswith('bpcheck'): query_cond = "(" for account in accounts: query_cond += "aa.code LIKE '" + account + "%' OR " query_cond = query_cond[:-4]+")" |
query = "SELECT aa.code AS code, SUM(debit) as debit, SUM(credit) as credit FROM account_move_line aml LEFT JOIN account_account aa ON aa.id=aml.account_id WHERE "+query_cond+closed_cond+" AND aml.state='valid' AND aml.period_id IN "+str(tuple(period_query_cond))+" GROUP BY code" self.cr.execute(query) | query = "SELECT aa.code AS code, SUM(debit) as debit, SUM(credit) as credit " \ " FROM account_move_line aml LEFT JOIN account_account aa ON aa.id=aml.account_id "\ " WHERE "+query_cond+closed_cond+" AND aml.state='valid' AND aml.period_id = ANY(%s) GROUP BY code" query_params.append(list(period_ids)) self.cr.execute(query, query_params) | def _load_accounts(self,form,code,definition,fiscalyear,period_query_cond): accounts = {} for x in definition['load']: p = x.split(":") accounts[p[1]] = [p[0],p[2]] sum = 0.0 if fiscalyear.state != 'done' or not code.startswith('bpcheck'): query_cond = "(" for account in accounts: query_cond += "aa.code LIKE '" + account + "%' OR " query_cond = query_cond[:-4]+")" |
cr.execute('insert into stock_move_history_ids (parent_id,child_id) values (%s,%s)', (move.id, move.move_dest_id.id)) | self.write(cr, uid, [move.id], {'move_history_ids': [(4, move.move_dest_id.id)]}) | 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: """ partial_datas='' picking_ids = [] partial_obj=self.pool.get('stock.partial.picking') partial_id=partial_obj.search(cr,uid,[]) if partial_id: partial_datas=partial_obj.read(cr,uid,partial_id)[0] if context is None: context = {} |
'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)'), 'category_holiday_id': fields.many2one('hr.holidays', 'Holiday', help='For allocation By Employee Category (Link between Employee Category holiday and related holidays for employees of that category)') | 'manager_id2': fields.many2one('hr.employee', 'Second Approval', readonly=True, help='This area is automaticly filled by the user who validate the leave with second level (If Leave type need second validation)') | def _employee_get(obj, cr, uid, context=None): ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if ids: return ids[0] return False |
def _get_category_leave_ids(self, cr, uid, ids): """Returns the leaves taken by the employees of the category if holiday type is 'category'.""" leave_ids = [] for record in self.browse(cr, uid, ids): if record.holiday_type == 'category' and record.type == 'remove': leave_ids += self.search(cr, uid, [('category_holiday_id', '=', record.id)]) return leave_ids | def _employee_get(obj, cr, uid, context=None): ids = obj.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context) if ids: return ids[0] return False |
|
ids += self._get_category_leave_ids(cr, uid, ids) | def unlink(self, cr, uid, ids, context=None): self._update_user_holidays(cr, uid, ids) ids += self._get_category_leave_ids(cr, uid, ids) self._remove_resouce_leave(cr, uid, ids, context=context) return super(hr_holidays, self).unlink(cr, uid, ids, context) |
|
elif record.holiday_type == 'category' and record.type == 'remove': | elif record.holiday_type == 'category': | def holidays_validate(self, cr, uid, ids, *args): obj_emp = self.pool.get('hr.employee') wf_service = netsvc.LocalService("workflow") data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) vals = {'state':'validate'} ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) if ids2: if data_holiday[0].state == 'validate1': vals['manager_id2'] = ids2[0] else: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'), _('No user related to the selected employee.')) self.write(cr, uid, ids, vals) for record in data_holiday: if record.holiday_type == 'employee' and record.type == 'remove': vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': record.employee_id.calendar_id.id, 'company_id': record.employee_id.company_id.id, 'resource_id': record.employee_id.resource_id.id, 'holiday_id': record.id } self._create_resource_leave(cr, uid, vals) elif record.holiday_type == 'category' and record.type == 'remove': emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': emp.calendar_id.id, 'company_id': emp.company_id.id, 'resource_id': emp.resource_id.id, 'holiday_id':record.id } |
'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': emp.calendar_id.id, 'company_id': emp.company_id.id, 'resource_id': emp.resource_id.id, 'holiday_id':record.id } for leave_id in self.search(cr, uid, [('category_holiday_id', '=', record.id)]): wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) | 'name': record.name, 'type': record.type, 'holiday_type': 'employee', 'holiday_status_id': record.holiday_status_id.id, 'date_from': record.date_from, 'date_to': record.date_to, 'notes': record.notes, 'number_of_days_temp': record.number_of_days_temp, 'parent_id': record.id, 'employee_id': emp.id } leave_ids.append(self.create(cr, uid, vals, context=None)) for leave_id in leave_ids: wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr) | def holidays_validate(self, cr, uid, ids, *args): obj_emp = self.pool.get('hr.employee') wf_service = netsvc.LocalService("workflow") data_holiday = self.browse(cr, uid, ids) self.check_holidays(cr, uid, ids) vals = {'state':'validate'} ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) if ids2: if data_holiday[0].state == 'validate1': vals['manager_id2'] = ids2[0] else: vals['manager_id'] = ids2[0] else: raise osv.except_osv(_('Warning !'), _('No user related to the selected employee.')) self.write(cr, uid, ids, vals) for record in data_holiday: if record.holiday_type == 'employee' and record.type == 'remove': vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': record.employee_id.calendar_id.id, 'company_id': record.employee_id.company_id.id, 'resource_id': record.employee_id.resource_id.id, 'holiday_id': record.id } self._create_resource_leave(cr, uid, vals) elif record.holiday_type == 'category' and record.type == 'remove': emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'date_from': record.date_from, 'date_to': record.date_to, 'calendar_id': emp.calendar_id.id, 'company_id': emp.company_id.id, 'resource_id': emp.resource_id.id, 'holiday_id':record.id } |
obj_emp = self.pool.get('hr.employee') wf_service = netsvc.LocalService("workflow") | def holidays_confirm(self, cr, uid, ids, *args): obj_hr_holiday_status = self.pool.get('hr.holidays.status') obj_emp = self.pool.get('hr.employee') wf_service = netsvc.LocalService("workflow") for record in self.browse(cr, uid, ids): user_id = False leave_asked = record.number_of_days_temp leave_ids = [] if record.holiday_type == 'employee' and record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s while there are too few remaining leave days.') % (record.employee_id.name)) nb = -(record.number_of_days_temp) elif record.holiday_type == 'category' and record.type == 'remove': if record.category_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days_cat( cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for category %s while there are too few remaining leave days.') % (record.category_id.name)) nb = -(record.number_of_days_temp) # Create leave request for employees in the category emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'holiday_status_id': record.holiday_status_id.id, 'date_from': record.date_from, 'date_to': record.date_to, 'notes': record.notes, 'number_of_days_temp': record.number_of_days_temp, 'category_holiday_id': record.id, 'employee_id': emp.id } leave_ids.append(self.create(cr, uid, vals, context=None)) # Confirm all the leave requests of the category for leave_id in leave_ids: wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) else: nb = record.number_of_days_temp |
|
leave_ids = [] | def holidays_confirm(self, cr, uid, ids, *args): obj_hr_holiday_status = self.pool.get('hr.holidays.status') obj_emp = self.pool.get('hr.employee') wf_service = netsvc.LocalService("workflow") for record in self.browse(cr, uid, ids): user_id = False leave_asked = record.number_of_days_temp leave_ids = [] if record.holiday_type == 'employee' and record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s while there are too few remaining leave days.') % (record.employee_id.name)) nb = -(record.number_of_days_temp) elif record.holiday_type == 'category' and record.type == 'remove': if record.category_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days_cat( cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for category %s while there are too few remaining leave days.') % (record.category_id.name)) nb = -(record.number_of_days_temp) # Create leave request for employees in the category emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'holiday_status_id': record.holiday_status_id.id, 'date_from': record.date_from, 'date_to': record.date_to, 'notes': record.notes, 'number_of_days_temp': record.number_of_days_temp, 'category_holiday_id': record.id, 'employee_id': emp.id } leave_ids.append(self.create(cr, uid, vals, context=None)) # Confirm all the leave requests of the category for leave_id in leave_ids: wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) else: nb = record.number_of_days_temp |
|
emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'holiday_status_id': record.holiday_status_id.id, 'date_from': record.date_from, 'date_to': record.date_to, 'notes': record.notes, 'number_of_days_temp': record.number_of_days_temp, 'category_holiday_id': record.id, 'employee_id': emp.id } leave_ids.append(self.create(cr, uid, vals, context=None)) for leave_id in leave_ids: wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) | def holidays_confirm(self, cr, uid, ids, *args): obj_hr_holiday_status = self.pool.get('hr.holidays.status') obj_emp = self.pool.get('hr.employee') wf_service = netsvc.LocalService("workflow") for record in self.browse(cr, uid, ids): user_id = False leave_asked = record.number_of_days_temp leave_ids = [] if record.holiday_type == 'employee' and record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days( cr, uid, [record.holiday_status_id.id], record.employee_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for employee %s while there are too few remaining leave days.') % (record.employee_id.name)) nb = -(record.number_of_days_temp) elif record.holiday_type == 'category' and record.type == 'remove': if record.category_id and not record.holiday_status_id.limit: leaves_rest = obj_hr_holiday_status.get_days_cat( cr, uid, [record.holiday_status_id.id], record.category_id.id, False)[record.holiday_status_id.id]['remaining_leaves'] if leaves_rest < leave_asked: raise osv.except_osv(_('Warning!'),_('You cannot validate leaves for category %s while there are too few remaining leave days.') % (record.category_id.name)) nb = -(record.number_of_days_temp) # Create leave request for employees in the category emp_ids = obj_emp.search(cr, uid, [('category_ids', '=', record.category_id.id)]) for emp in obj_emp.browse(cr, uid, emp_ids): vals = { 'name': record.name, 'holiday_status_id': record.holiday_status_id.id, 'date_from': record.date_from, 'date_to': record.date_to, 'notes': record.notes, 'number_of_days_temp': record.number_of_days_temp, 'category_holiday_id': record.id, 'employee_id': emp.id } leave_ids.append(self.create(cr, uid, vals, context=None)) # Confirm all the leave requests of the category for leave_id in leave_ids: wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr) else: nb = record.number_of_days_temp |
|
self.write(cr, uid, ids, {'state': 'cancel'}) leave_ids = self._get_category_leave_ids(cr, uid, ids) if leave_ids: self.unlink(cr, uid, leave_ids) | def holidays_cancel(self, cr, uid, ids, *args): self._update_user_holidays(cr, uid, ids) self._remove_resouce_leave(cr, uid, ids) self.write(cr, uid, ids, {'state': 'cancel'}) leave_ids = self._get_category_leave_ids(cr, uid, ids) if leave_ids: self.unlink(cr, uid, leave_ids) # unlink all the leave requests of the category return True |
|
'account_id': line.account_id.id, | 'account_id': result.get('account_id', statement.journal_id.default_credit_account_id.id), | def populate_statement(self, cr, uid, ids, context=None): |
context.update({'move_line_ids': [line.id]}) result = voucher_obj.onchange_partner_id(cr, uid, [], partner_id=line.partner_id.id, journal_id=statement.journal_id.id, price=abs(amount), currency_id= statement.currency.id, ttype=(amount < 0 and 'payment' or 'receipt'), context=context) | def populate_statement(self, cr, uid, ids, context=None): |
|
data = obj_pool.browse(cr, uid, data_id[0]) | data = obj_data.browse(cr, uid, data_id[0]) | def execute(self, cr, uid, ids, context=None): obj_multi = self.browse(cr, uid, ids[0]) 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') obj_data = self.pool.get('ir.model.data') analytic_journal_obj = self.pool.get('account.analytic.journal') obj_tax_code = self.pool.get('account.tax.code') # Creating Account obj_acc_root = obj_multi.chart_template_id.account_root_id tax_code_root_id = obj_multi.chart_template_id.tax_code_root_id.id company_id = obj_multi.company_id.id |
self.write(cr, uid, [inv.id], {'state':'done'}, context=context) | self.write(cr, uid, [inv.id], {'state':'done', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context) | def action_done(self, cr, uid, ids, context=None): move_obj = self.pool.get('stock.move') for inv in self.browse(cr, uid, ids, context=context): move_obj.action_done(cr, uid, [x.id for x in inv.move_ids], context=context) self.write(cr, uid, [inv.id], {'state':'done'}, context=context) return True |
self.write(cr, uid, [inv.id], {'state': 'confirm', 'date_done': time.strftime('%Y-%m-%d %H:%M:%S'), 'move_ids': [(6, 0, move_ids)]}) | self.write(cr, uid, [inv.id], {'state': 'confirm', 'move_ids': [(6, 0, move_ids)]}) | def action_confirm(self, cr, uid, ids, context=None): """ Finishes the inventory and writes its finished date @return: True """ if context is None: context = {} |
'product_qty': fields.float('Date End', digits=(16,2)), | 'product_qty': fields.float('Quantity', digits=(16,2)), | def tender_done(self, cr, uid, ids, context={}): self.write(cr, uid, ids, {'state':'done'}, context=context) return True |
cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to-install', 'to upgrade') ") | cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to install', 'to upgrade') ") | def db_list(self): """Get the list of available databases, with FTPd support """ s = netsvc.ExportService.getService('db') result = s.exp_list(document=True) self.db_name_list = [] for db_name in result: db, cr = None, None try: try: db = pooler.get_db_only(db_name) cr = db.cursor() cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'") if not cr.fetchone(): continue |
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'product.supplierinfo', context=c) | 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'product.supplierinfo', context=c), 'product_uom': _get_uom_id, | def _get_uom_id(self, cr, uid, *args): cr.execute('select id from product_uom order by id limit 1') res = cr.fetchone() return res and res[0] or False |
raise osv.except_osv(_('Error!'), _('Can not create Journal Entry, Output Account defined on this product and Variant account on category of this product is same.')) | raise osv.except_osv(_('Error!'), _('Can not create Journal Entry, Output Account defined on this product and Variant account on category of this product are same.')) | def _get_accounting_data_for_valuation(self, cr, uid, move, context=None): """ Return the accounts and journal to use to post Journal Entries for the real-time valuation of the move. |
raise osv.except_osv(_('Error!'), _('Can not create Journal Entry, Input Account defined on this product and Variant account on category of this product is same.')) | raise osv.except_osv(_('Error!'), _('Can not create Journal Entry, Input Account defined on this product and Variant account on category of this product are same.')) | def _get_accounting_data_for_valuation(self, cr, uid, move, context=None): """ Return the accounts and journal to use to post Journal Entries for the real-time valuation of the move. |
""" Finished the inventory | """ Finish the inventory | def action_done(self, cr, uid, ids, context=None): """ Finished the inventory @return: True """ |
'product_id' : self._getEmployeeProduct(cr,user_id, context= {}), 'product_uom_id' : self._getEmployeeUnit(cr, user_id, context= {}), 'general_account_id' :self. _getGeneralAccount(cr, user_id, context= {}), 'journal_id' : self._getAnalyticJournal(cr, user_id, context= {}), | 'product_id' : self._getEmployeeProduct(cr, uid, context), 'product_uom_id' : self._getEmployeeUnit(cr, uid, context), 'general_account_id' :self._getGeneralAccount(cr, uid, context), 'journal_id' : self._getAnalyticJournal(cr, uid, context), | def on_change_user_id(self, cr, uid, ids, user_id): if not user_id: return {} return {'value' : { 'product_id' : self._getEmployeeProduct(cr,user_id, context= {}), 'product_uom_id' : self._getEmployeeUnit(cr, user_id, context= {}), 'general_account_id' :self. _getGeneralAccount(cr, user_id, context= {}), 'journal_id' : self._getAnalyticJournal(cr, user_id, context= {}), }} |
if case.type == 'lead': | if case.type == 'lead' or context.get('stage_type',False)=='lead': | def write(self, cr, uid, ids, vals, context=None): if 'date_closed' in vals: return super(crm_lead,self).write(cr, uid, ids, vals, context=context) if 'stage_id' in vals and vals['stage_id']: stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context) self.history(cr, uid, ids, _('Stage'), details=stage_obj.name) message='' for case in self.browse(cr, uid, ids, context=context): if case.type == 'lead': message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, case.stage_id.name) elif case.type == 'opportunity': message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, case.stage_id.name) self.log(cr, uid, case.id, message) return super(crm_lead,self).write(cr, uid, ids, vals, context) |
self.log(cr, uid, case.id, message) | def write(self, cr, uid, ids, vals, context=None): if 'date_closed' in vals: return super(crm_lead,self).write(cr, uid, ids, vals, context=context) if 'stage_id' in vals and vals['stage_id']: stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context) self.history(cr, uid, ids, _('Stage'), details=stage_obj.name) message='' for case in self.browse(cr, uid, ids, context=context): if case.type == 'lead': message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, case.stage_id.name) elif case.type == 'opportunity': message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, case.stage_id.name) self.log(cr, uid, case.id, message) return super(crm_lead,self).write(cr, uid, ids, vals, context) |
|
message = _('Purchase order ') + " '" + purchase.name + "' "+ _("is cancelled") self.log(cr, uid, id, message) | for (id,name) in self.name_get(cr, uid, ids): message = _('Purchase order ') + " '" + purchase.name + "' "+ _("is cancelled") self.log(cr, uid, id, message) | def action_cancel(self, cr, uid, ids, context={}): ok = True purchase_order_line_obj = self.pool.get('purchase.order.line') for purchase in self.browse(cr, uid, ids): for pick in purchase.picking_ids: if pick.state not in ('draft','cancel'): raise osv.except_osv( _('Could not cancel purchase order !'), _('You must first cancel all picking attached to this purchase order.')) for pick in purchase.picking_ids: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr) inv = purchase.invoice_id if inv and inv.state not in ('cancel','draft'): raise osv.except_osv( _('Could not cancel this purchase order !'), _('You must first cancel all invoices attached to this purchase order.')) if inv: wf_service = netsvc.LocalService("workflow") wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr) self.write(cr,uid,ids,{'state':'cancel'}) message = _('Purchase order ') + " '" + purchase.name + "' "+ _("is cancelled") self.log(cr, uid, id, message) return True |
uos = False result.update({'type': product_obj.procure_method}) | uos = False | def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False): if not partner_id: raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sale form !\nPlease set one customer before choosing a product.')) warning = {} product_uom_obj = self.pool.get('product.uom') partner_obj = self.pool.get('res.partner') product_obj = self.pool.get('product.product') if partner_id: lang = partner_obj.browse(cr, uid, partner_id).lang context = {'lang': lang, 'partner_id': partner_id} |
order_obj=self.pool.get('pos.order') record_id=context.get('record_id') | order_obj = self.pool.get('pos.order') active_ids = context.get('active_ids') | def default_get(self, cr, uid, fields, context=None): """ 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. """ |
for order in order_obj.browse(cr, uid,[record_id]): | for order in order_obj.browse(cr, uid, active_ids): | def default_get(self, cr, uid, fields, context=None): """ 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. """ |
context={} record_id=context.get('record_id') for order in order_obj.browse(cr, uid,[record_id]): | context={} active_ids=context.get('active_ids') for order in order_obj.browse(cr, uid, active_ids): | def view_init(self, cr, uid, fields_list, context=None): res = super(pos_return, self).view_init(cr, uid, fields_list, context=context) order_obj=self.pool.get('pos.order') if not context: context={} record_id=context.get('record_id') for order in order_obj.browse(cr, uid,[record_id]): for line in order.lines: if 'return%s'%(line.id) not in self._columns: self._columns['return%s'%(line.id)] = fields.float("Quantity") return res |
order_obj=self.pool.get('pos.order') record_id = context.get('record_id', False) if record_id: | active_model = context.get('active_model') if not active_model and active_model != 'pos.order': return result order_obj = self.pool.get('pos.order') active_id = context.get('active_id', False) if active_id: | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(pos_return, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) if not context: context={} order_obj=self.pool.get('pos.order') record_id = context.get('record_id', False) if record_id: _moves_arch_lst="""<?xml version="1.0"?> <form string="Return lines"> <label string="Quantities you enter, match to products that will return to the stock." colspan="4"/>""" _line_fields = result['fields'] order=order_obj.browse(cr, uid, record_id) for line in order.lines: quantity=line.qty _line_fields.update({ 'return%s'%(line.id) : { 'string': line.product_id.name, 'type' : 'float', 'required': True, 'default':quantity }, }) _moves_arch_lst += """ <field name="return%s"/> <newline/> """%(line.id) _moves_arch_lst+=""" <newline/> <separator colspan="4"/> <button icon='gtk-cancel' special="cancel" string="Cancel" /> <button icon='gtk-ok' name= "create_returns" string="Return goods and Exchange" type="object"/> <button icon='gtk-ok' name="create_returns2" string="Return without Refund" type="object"/> </form>""" result['arch'] = _moves_arch_lst result['fields'] = _line_fields return result |
order=order_obj.browse(cr, uid, record_id) | order=order_obj.browse(cr, uid, active_id) | def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False,submenu=False): result = super(pos_return, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu) if not context: context={} order_obj=self.pool.get('pos.order') record_id = context.get('record_id', False) if record_id: _moves_arch_lst="""<?xml version="1.0"?> <form string="Return lines"> <label string="Quantities you enter, match to products that will return to the stock." colspan="4"/>""" _line_fields = result['fields'] order=order_obj.browse(cr, uid, record_id) for line in order.lines: quantity=line.qty _line_fields.update({ 'return%s'%(line.id) : { 'string': line.product_id.name, 'type' : 'float', 'required': True, 'default':quantity }, }) _moves_arch_lst += """ <field name="return%s"/> <newline/> """%(line.id) _moves_arch_lst+=""" <newline/> <separator colspan="4"/> <button icon='gtk-cancel' special="cancel" string="Cancel" /> <button icon='gtk-ok' name= "create_returns" string="Return goods and Exchange" type="object"/> <button icon='gtk-ok' name="create_returns2" string="Return without Refund" type="object"/> </form>""" result['arch'] = _moves_arch_lst result['fields'] = _line_fields return result |
record_id = context.get('record_id', False) | active_id = context.get('active_id', False) | def create_returns2(self, cr, uid, ids, context): record_id = context.get('record_id', False) order_obj =self.pool.get('pos.order') line_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") uom_obj =self. pool.get('product.uom') wf_service = netsvc.LocalService("workflow") #Todo :Need to clean the code if record_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) data=self.read(cr,uid,ids)[0] clone_list = [] date_cur=time.strftime('%Y-%m-%d') |
if record_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) | if active_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[active_id]), ('state', '=', 'done')]) | def create_returns2(self, cr, uid, ids, context): record_id = context.get('record_id', False) order_obj =self.pool.get('pos.order') line_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") uom_obj =self. pool.get('product.uom') wf_service = netsvc.LocalService("workflow") #Todo :Need to clean the code if record_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) data=self.read(cr,uid,ids)[0] clone_list = [] date_cur=time.strftime('%Y-%m-%d') |
for order_id in order_obj.browse(cr, uid, [record_id], context=context): | for order_id in order_obj.browse(cr, uid, [active_id], context=context): | def create_returns2(self, cr, uid, ids, context): record_id = context.get('record_id', False) order_obj =self.pool.get('pos.order') line_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") uom_obj =self. pool.get('product.uom') wf_service = netsvc.LocalService("workflow") #Todo :Need to clean the code if record_id: picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) data=self.read(cr,uid,ids)[0] clone_list = [] date_cur=time.strftime('%Y-%m-%d') |
if not context.get('record_id', False): | if not context.get('active_id', False): | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
record_id=context.get('record_id', False) | active_id=context.get('active_id', False) | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) | picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[active_id]), ('state', '=', 'done')]) | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) | order_obj.add_product(cr, uid, active_id,data['product_id'],data['quantity'], context=context) | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
for order_id in order_obj.browse(cr, uid, [record_id], context=context): | for order_id in order_obj.browse(cr, uid, [active_id], context=context): | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) | order_obj.write(cr,uid,active_id,{'last_out_picking':new_picking}) | def select_product(self, cr, uid, ids, context): """ To get the product and quantity and add in order . @param self: The object pointer. @param cr: A database cursor @param uid: ID of the user currently logged in @param context: A standard dictionary @return : Retrun the add product form again for adding more product """ if not context.get('record_id', False): super(add_product).select_product(cr,uid,ids) else: record_id=context.get('record_id', False) data = self.read(cr, uid, ids)[0] order_obj = self.pool.get('pos.order') lines_obj = self.pool.get('pos.order.line') picking_obj = self.pool.get('stock.picking') stock_move_obj = self.pool.get('stock.move') move_obj = self.pool.get('stock.move') property_obj= self.pool.get("ir.property") invoice_obj= self.pool.get('account.invoice') picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in',[record_id]), ('state', '=', 'done')]) clone_list = [] date_cur=time.strftime('%Y-%m-%d') uom_obj = self.pool.get('product.uom') prod_obj=self.pool.get('product.product') wf_service = netsvc.LocalService("workflow") return_boj=self.pool.get('pos.return') order_obj.add_product(cr, uid, record_id,data['product_id'],data['quantity'], context=context) for order_id in order_obj.browse(cr, uid, [record_id], context=context): prod=data['product_id'] qty=data['quantity'] prop_ids = property_obj.search(cr, uid,[('name', '=', 'property_stock_customer')]) val = property_obj.browse(cr, uid,prop_ids[0]).value_reference cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order_id.shop_id.warehouse_id.id)) res=cr.fetchone() location_id=res and res[0] or None stock_dest_id = val.id prod_id=prod_obj.browse(cr,uid,prod) new_picking=picking_obj.create(cr,uid,{ 'name':'%s (Added)' %order_id.name, 'move_lines':[], 'state':'draft', 'type':'out', 'date':date_cur, }) new_move=stock_move_obj.create(cr, uid,{ 'product_qty': qty, 'product_uos_qty': uom_obj._compute_qty(cr, uid,prod_id.uom_id.id, qty, prod_id.uom_id.id), 'picking_id':new_picking, 'product_uom':prod_id.uom_id.id, 'location_id':location_id, 'product_id':prod_id.id, 'location_dest_id':stock_dest_id, 'name':'%s (return)' %order_id.name, 'date':date_cur, 'date_planned':date_cur,}) wf_service.trg_validate(uid, 'stock.picking',new_picking,'button_confirm', cr) picking_obj.force_assign(cr, uid, [new_picking], context) order_obj.write(cr,uid,record_id,{'last_out_picking':new_picking}) return { 'name': _('Add Product'), 'view_type': 'form', 'view_mode': 'form', 'res_model': 'pos.add.product', 'view_id': False, 'target':'new', 'context':context, 'views': False, 'type': 'ir.actions.act_window', } |
record_id=context.get('record_id', False) | active_id=context.get('active_id', False) | def close_action(self, cr, uid, ids, context): |
picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', [record_id]), ('state', '=', 'done')]) | picking_ids = picking_obj.search(cr, uid, [('pos_order', 'in', [active_id]), ('state', '=', 'done')]) | def close_action(self, cr, uid, ids, context): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.