class born_shop_category(models.Model): _name = 'born.shop.category' @api.one @api.depends('image') def _make_local_url(self): for line in self: if self.image: domain = [('type', '=', 'binary'), ('res_field', '=', 'image'), ('res_model', '=', 'born.shop.category'), ('res_id', '=', self.id)] attachment = self.env['ir.attachment'].search(domain, limit=1) if attachment: server_url = openerp.tools.config['localhost_server_url'] image_url = '%s%s' % (server_url, attachment.local_url) line.image_url = image_url name = fields.Char(u'名称') image = fields.Binary(u'标志图片', attachment=True) image_url = fields.Char(string=u'图片地址', compute='_make_local_url', multi='_make_local_url', help=u"图片地址") type = fields.Selection([('url', u'链接'), ('product_ids', u'商品'), ('category_ids', u'分类'), ('content_ids', u'文章'), ('function_ids', u'功能')], default='url', string=u'类型', help=u'类型') sequence = fields.Integer(u'排序') description = fields.Text(u'说明')
class account_voucher(models.Model): _inherit= "account.voucher" enviado = fields.Boolean(string="Enviado") veces_descarga = fields.Integer(string="# Descargado") egreso = fields.Char('Egreso', readonly=True, copy=False) res_partner_bank_id = fields.Many2one('res.partner.bank',string="Banco") cod_proveedor = fields.Char(related='res_partner_bank_id.bank_bic',string="Codigo de Proveedor en el Banco") partner_id_related = fields.Many2one(related='partner_id',string="Proveedir") @api.multi def default_banco_ids(self, partner_id_related): obj_datos=self.env['res.partner.bank'].search([('partner_id','=',partner_id_related)]) if len(obj_datos)==1: return { 'value': { 'res_partner_bank_id': obj_datos.id, } } @api.model def create(self, vals): seq = self.env['ir.sequence'].next_by_code('account.voucher') or '/' vals['egreso'] = seq a = super(account_voucher, self).create(vals) return a
class category_code(models.Model): _name = 'category.code' _rec_name = 'code' code = fields.Char('Code') description = fields.Char('Description')
class GolCompany(osv.osv): _name = 'res.company' _inherit = 'res.company' #Para el eliminar el tex area en empresa overdue_msg = fields.Text('Descripción') tradename = fields.Char('Nombre Comercial', size=80) phone2 = fields.Char('Teléfono 2', size=15) phone3 = fields.Char('Teléfono 3', size=15) riseUse = fields.Selection( [('rise', 'Rise'), ('contributorSpecial', 'Contribuyente Especial')], 'Seleccione', default='rise', required=True) identificationType = fields.Many2one('gol.identification.type', 'Tipo de Identificación') identificationNumber = fields.Char( 'Número de Identificación', help='Ingrese el numero de identificación') typePerson = fields.Many2one('gol.type.person', 'Tipo de persona') bussinesName = fields.Char('Razón Social', help='Ingrese el razón social') forcedToTakeAccounting = fields.Boolean('Obligado a llevar contabilidad', default=False) accountant = fields.Many2one('gol.accountant', 'Contador') taxLiability = fields.One2many('gol.tax.liability', 'idCompany', 'Obligaciones Tributarias') legalRepresentative = fields.Many2one('gol.contact', 'Representante Legal') formatCorrelative = fields.Many2one('gol.format.correlative', 'Formatos Correlativos') child_contact_ids = fields.One2many('res.partner', 'parent_id', 'Contacts', domain=[('active', '=', True)]),
class AsteriskServer(models.Model): _inherit = 'asterisk.server' server_starturl=fields.Char(string="URL", placeholder="https://mypbx.qlan.eu/pbx/proxyapi.php") server_key=fields.Char(string="Key") server_tenant=fields.Char(string="Tenant") server_timeout=fields.Char(string="Timeout") server_cid=fields.Char(string="CID", help="Default caller id to use") def _get_calling_number(self, cr, uid, context=None): _logger.info("Start _get_calling_number lubon_asterisk") user, ast_server, ast_manager = self._connect_to_asterisk( cr, uid, context=context) calling_party_number = False try: list_chan = ast_manager.Status() #pdb.set_trace() #from pprint import pprint #pprint(list_chan) _logger.debug("Result of Status AMI request: %s", list_chan) for chan in list_chan.values(): sip_account = user.asterisk_chan_type + '/' + user.resource # 4 = Ring if ( chan.get('ChannelState') == '4' and chan.get('ConnectedLineNum') == user.internal_number): _logger.debug("Found a matching Event in 'Ring' state") calling_party_number = chan.get('CallerIDNum') break # 6 = Up if ( chan.get('ChannelState') == '6' and sip_account in chan.get('BridgedChannel', '')): _logger.debug("Found a matching Event in 'Up' state") calling_party_number = chan.get('CallerIDNum') break if ( chan.get('ChannelState') == '6' and chan.get('ConnectedLineNum') == user.internal_number): _logger.debug("Found a matching Event in 'Ring' state") calling_party_number = chan.get('CallerIDNum') break # Compatibility with Asterisk 1.4 if ( chan.get('State') == 'Up' and sip_account in chan.get('Link', '')): _logger.debug("Found a matching Event in 'Up' state") calling_party_number = chan.get('CallerIDNum') break except Exception, e: _logger.error( "Error in the Status request to Asterisk server %s" % ast_server.ip_address) _logger.error( "Here are the details of the error: '%s'" % unicode(e)) raise orm.except_orm( _('Error:'), _("Can't get calling number from Asterisk.\nHere is the " "error: '%s'" % unicode(e))) finally:
class tools_helpdesk_contexto_nivel1(models.Model): """Estructura de Dependencias Administrativas""" _name = 'tools.helpdesk.contexto_nivel1' _rec_name = 'nombre' codigo = fields.Char(string="Código", size=20, help='Código de la Aplicación') nombre = fields.Char(string="Nombre", size=60, help='Nombre de la Aplicación') descripcion = fields.Text(string="Descripción", help='Descripción de la Aplicación') res_partner_ids = fields.Many2many( 'res.partner', 'respartner_aplicacion_rel', 'contexto_nivel1_id', 'res_partner_id', string="Organización", help='Organización que implementa esta aplicación') contexto_nivel2_ids = fields.One2many( 'tools.helpdesk.contexto_nivel2', 'contexto_nivel1_id', string="Módulo", help='Módulos que pertenecen a esta Aplicación')
class Category(models.Model): _name = 'test_new_api.category' name = fields.Char(required=True) parent = fields.Many2one('test_new_api.category') display_name = fields.Char(compute='_compute_display_name', inverse='_inverse_display_name') dummy = fields.Char(store=False) @api.one @api.depends('name', 'parent.display_name') # this definition is recursive def _compute_display_name(self): if self.parent: self.display_name = self.parent.display_name + ' / ' + self.name else: self.display_name = self.name @api.one def _inverse_display_name(self): names = self.display_name.split('/') # determine sequence of categories categories = [] for name in names[:-1]: category = self.search([('name', 'ilike', name.strip())]) categories.append(category[0]) categories.append(self) # assign parents following sequence for parent, child in zip(categories, categories[1:]): if parent and child: child.parent = parent # assign name of last category, and reassign display_name (to normalize it) self.name = names[-1].strip()
class GolInvoice(osv.Model): _name = 'account.invoice' _inherit = 'account.invoice' documentType = fields.Many2one('gol.document.type') amountPaid = fields.Float('Monto Abonado', compute='_GetAmountPaid', Store=True) purchaseOrder = fields.Char('Orden de Compra') contractName = fields.Char('Nombre del Contrato') authorizationNumber = fields.Char('Número de Autorización') description = fields.Text('Observación') amountDiscount = fields.Float('Descuentos') #Elementos Modificados date_invoice = fields.Date('Fecha', default=datetime.now().strftime('%Y-%m-%d')) #Metodos Modificados @api.one @api.constrains('invoice_line') @api.onchange('partner_id', 'invoice_line') def ValidateFields(self): if (self.partner_id == False): raise ValidationError('Usted debe seleccionar un cliente') @api.one def _GetAmountPaid(self): self.amountPaid = self.amount_total - self.residual
class stagiaires(models.Model): _name = "hr.stagiaires" _description = "liste des stagiaires" _rec_name = "nom" image = fields.Binary('Image') nom = fields.Char("Nom du stagiaire") adresse_pro = fields.Char("Adresse Professionelle") tel_pro = fields.Char('Tél. portable professionel') user_id = fields.Many2one('res.users', string="Utilisateur lié") departement = fields.Many2one('hr.department', string="Département") job = fields.Many2one('hr.job', string="Titre de poste") responsa = fields.Many2one('hr.employee', string="Responsable") date_entre = fields.Date('Date debut') date_fin = fields.Date('Date fin de stage') nationalite = fields.Many2one('res.country', string="Nationalité") cin = fields.Integer('CIN') deliv = fields.Date('Date delivrance CIN') naiss = fields.Date('Date naissance') naisslieux = fields.Many2one('res.country.state', string="Lieux de naissance") pers_addr = fields.Char('Adresse personnelle') gender = fields.Selection(selection=[('Masculin', 'Masculin'), ('Feminin', 'Feminin')], string="Genre") etciv = fields.Selection(selection=[('Divorcé', 'Divorcé'), ('Marié', 'Marié'), ('Celibataire', 'Celibataire'), ('Voeuf', 'Voeuf')], string="etat Civil") actif = fields.Boolean('Active') theme = fields.Char('Théme de stage')
class Message(models.Model): _name = 'test_new_api.message' discussion = fields.Many2one('test_new_api.discussion', ondelete='cascade') body = fields.Text() author = fields.Many2one('res.users', default=lambda self: self.env.user) name = fields.Char(string='Title', compute='_compute_name', store=True) display_name = fields.Char(string='Abstract', compute='_compute_display_name') size = fields.Integer(compute='_compute_size', search='_search_size') double_size = fields.Integer(compute='_compute_double_size') discussion_name = fields.Char(related='discussion.name') @api.one @api.constrains('author', 'discussion') def _check_author(self): if self.discussion and self.author not in self.discussion.participants: raise ValueError( _("Author must be among the discussion participants.")) @api.one @api.depends('author.name', 'discussion.name') def _compute_name(self): self.name = "[%s] %s" % (self.discussion.name or '', self.author.name or '') @api.one @api.depends('author.name', 'discussion.name', 'body') def _compute_display_name(self): stuff = "[%s] %s: %s" % (self.author.name, self.discussion.name or '', self.body or '') self.display_name = stuff[:80] @api.one @api.depends('body') def _compute_size(self): self.size = len(self.body or '') def _search_size(self, operator, value): if operator not in ('=', '!=', '<', '<=', '>', '>=', 'in', 'not in'): return [] # retrieve all the messages that match with a specific SQL query query = """SELECT id FROM "%s" WHERE char_length("body") %s %%s""" % \ (self._table, operator) self.env.cr.execute(query, (value, )) ids = [t[0] for t in self.env.cr.fetchall()] return [('id', 'in', ids)] @api.one @api.depends('size') def _compute_double_size(self): # This illustrates a subtle situation: self.double_size depends on # self.size. When size is computed, self.size is assigned, which should # normally invalidate self.double_size. However, this may not happen # while self.double_size is being computed: the last statement below # would fail, because self.double_size would be undefined. self.double_size = 0 size = self.size self.double_size = self.double_size + size
class res_region(models.Model): _name = "res.region" _description = "Regions" _order = "name" name = fields.Char(string="Region Name", required=True) code = fields.Char(string="Code") city = fields.Many2one('res.city', string="City", required=True)
class born_lottery(osv.osv): _name = 'born.lottery' name = fields.Char(u'名称', size=255, help=u"名称") path = fields.Char(u'文件夹名称', size=255, help=u"文件夹名称") image = fields.Binary(u"预览") level = fields.Integer(u'中奖等级', digits=(2, 0)) description = fields.Text(u'说明', )
class res_city(models.Model): _name = "res.city" _description = "Cities" _order = "name" name = fields.Char(string="City Name", required=True) code = fields.Char(string="Code") state = fields.Many2one('res.country.state', string="State", required=True)
class res_kelurahan(models.Model): _name = "res.kelurahan" _description = "List Kelurahan" name = fields.Char(string='Kelurahan') state_id = fields.Many2one('res.country.state', string="Province") kabupaten_id = fields.Many2one('res.kabupaten', string="Kabupaten") kecamatan_id = fields.Many2one('res.kecamatan', string="Kabupaten") zip = fields.Char("Kode Post")
class born_activity_tpl(osv.osv): _name = 'born.activity.tpl' _description = u"模板" name = fields.Char(u'名称', size=255, help=u"活动名称", required=True) image = fields.Binary(string=u"活动海报", attachment=True, help=u"活动海报") image_url = fields.Char(u'海报地址', size=255, help=u"海报地址") file_name = fields.Char(u'海报名称', size=255, help=u"海报名称") note = fields.Text(u'活动简介', required=True, help=u'活动简介') description = fields.Text(u'活动描叙', required=True, help=u'活动详细描叙,活动参与流程') provision = fields.Text(u'活动条款', help=u'参与活动的条款') active = fields.Boolean(u'归档', default=True) price = fields.Float(u'报名费', help=u'参与活动的报名费用') company_id = fields.Many2one('res.company', u'公司', ondelete='cascade', required=True, help=u'活动所属公司') game_id = fields.Many2one('born.game', u'游戏', help=u'参与活动的游戏') app_id = fields.Many2one('tl.weixin.app', u'公众号', ondelete="cascade") activity_ids = fields.One2many('born.activity', 'active_tpl_id', string=u'活动', help=u'商户报名活动列表') company_ids = fields.Many2many('res.company', 'born_activity_company_rel', 'activity_id', 'company_id', u'允许发行的公司', help=u'限制该活动允许发行的公司,不设置表示所有的平台都可以看到该活动') default_gift_ids = fields.Many2many('born.game.gift', 'born_activity_default_gift_rel', 'activity_id', 'gift_id', u'默认奖品', help=u'该奖品为发行活动的公司提供,所有参与的公司都能够使用该奖品') @api.model def create(self, vals): if vals.get('image', False): s3 = s3client(self) image_url = s3.upload(self._cr, self._uid, vals.get('image'), vals.get('file_name', 'image.png')) vals['image_url'] = image_url return super(born_activity_tpl, self).create(vals) @api.multi def write(self, vals): if vals.get('image', False): s3 = s3client(self) image_url = s3.upload(self._cr, self._uid, vals.get('image'), vals.get('file_name', 'image.png')) vals['image_url'] = image_url return super(born_activity_tpl, self).write(vals)
class res_partner(osv.osv): _inherit = "res.partner" taxation = fields.Selection([('Tax Payer','Tax Payer'),('Non Tax Payer','Non Tax Payer')], default='Non Tax Payer', String='Tax Condition', required=True) ntn = fields.Char(string="NTN", domain=[('taxation','=','n-pay')]) nic = fields.Char(string="NIC") strn = fields.Char(string="STRN") gst = fields.Char(string="GST") city_id = fields.Many2one('res.city', string="City", required=True) region_id = fields.Many2one('res.region', string="Region", required=True) custom_type = fields.Selection([('department','WH Department')], 'Type', store=True)
class od_document_request_attach_here_line(models.Model): _name = 'od.document.request.attach.here.line' _description = "od.document.request.attach.here.line" name = fields.Char(string='Description') scanned_copy = fields.Binary(string='Scanned Copy') scanned_fname = fields.Char(string='Comp', size=32) reference = fields.Char(string='Reference') issue_date = fields.Date(string='Issue Date') expiry_date = fields.Date(string='Expiry Date') document_attach_here_line_id = fields.Many2one('od.document.request', string='Document')
class GolValidatorRetention(osv.Model): _name = 'gol.validator.retention' _description = u'descripcion modulo' #Decalaracion de campos initialCorrelative = fields.Char('Correlativo inicial', size=50, required=True) correlativeEnd = fields.Char('Correlativo Final', size=50, required=True) broadcastDate = fields.Datetime('Fecha de Emisión') expirationDate = fields.Datetime('Fecha de Caducidad') authorizationNumber = fields.Char('Número de Autorización') idRulesRetention = fields.Many2one('res.partner', 'Reglas Retención')
class Category(models.Model): _name = 'test_new_api.category' name = fields.Char(required=True) color = fields.Integer('Color Index') parent = fields.Many2one('test_new_api.category') root_categ = fields.Many2one(_name, compute='_compute_root_categ') display_name = fields.Char(compute='_compute_display_name', inverse='_inverse_display_name') dummy = fields.Char(store=False) discussions = fields.Many2many('test_new_api.discussion', 'test_new_api_discussion_category', 'category', 'discussion') @api.one @api.depends('name', 'parent.display_name') # this definition is recursive def _compute_display_name(self): if self.parent: self.display_name = self.parent.display_name + ' / ' + self.name else: self.display_name = self.name @api.depends('parent') def _compute_root_categ(self): for cat in self: current = cat while current.parent: current = current.parent cat.root_categ = current @api.one def _inverse_display_name(self): names = self.display_name.split('/') # determine sequence of categories categories = [] for name in names[:-1]: category = self.search([('name', 'ilike', name.strip())]) categories.append(category[0]) categories.append(self) # assign parents following sequence for parent, child in zip(categories, categories[1:]): if parent and child: child.parent = parent # assign name of last category, and reassign display_name (to normalize it) self.name = names[-1].strip() @api.multi def read(self, fields=None, load='_classic_read'): if self.search_count([('id', 'in', self._ids), ('name', '=', 'NOACCESS')]): raise AccessError('Sorry') return super(Category, self).read(fields=fields, load=load)
class student(models.Model): _name = 'teacher' name = fields.Char('Name', required=1) address = fields.Text('Address') pincode = fields.Char('Pincode') telephone = fields.Char('Telephone') birthdate = fields.Date('Birthdate') joindate = fields.Datetime('Join Date') active = fields.Boolean('Active', default=1) def active_action(self): print self
class od_employee_document_type(osv.osv): _name = 'od.employee.document.type' _description = "od.employee.document.type" name = fields.Char(string='Name', required=True, size=64) code = fields.Char(string='Code', size=32) description = fields.Text(string='Description') custodian = fields.Selection([ ('employee', 'Employee'), ('company', 'Company'), ], string='Custodian', required="1", default='company')
class student(models.Model): _name = 'student' name = fields.Char('Name', required=1) address = fields.Text('Address') pincode = fields.Char('Pincode') telephone = fields.Char('Telephone') birthdate = fields.Date('Birthdate') joindate = fields.Datetime('Join Date') roll_no = fields.Integer('Roll Number') fees_amt = fields.Float('Fees') active = fields.Boolean('Active', default=1) stand = fields.Selection([('one', 'One'), ('two', 'Two'), ('three', 'Three'), ('four', 'Four')], 'Stand.')
class born_address(osv.osv): _name = 'born.address' user_name = fields.Char(u'收货人', size=255, help=u"收货人") phone = fields.Char(u'电话', size=255, help=u"电话") address = fields.Char(u'详细地址', size=255, help=u"详细地址") default = fields.Boolean(u'默认地址', help=u"默认地址") country_id = fields.Many2one('res.country', u'国家', ondelete='restrict') state_id = fields.Many2one("res.country.state", u'省', ondelete='restrict') area_id = fields.Many2one('res.country.state.area', u'市') subdivide_id = fields.Many2one('res.country.state.area.subdivide', u'区域', select=True, track_visibility='onchange')
class ComputeRecursive(models.Model): _name = 'test_new_api.recursive' name = fields.Char(required=True) parent = fields.Many2one('test_new_api.recursive') display_name = fields.Char(compute='_compute_display_name', store=True) @api.depends('name', 'parent.display_name') def _compute_display_name(self): for rec in self: if rec.parent: rec.display_name = rec.parent.display_name + " / " + rec.name else: rec.display_name = rec.name
class GrpSeleccionVariantesLineas(models.Model): _name = 'grp.seleccion.variantes.lineas' product_id = fields.Many2one( comodel_name='product.template', string=u'Producto' ) para_crear = fields.Boolean(u'Para Crear', default=False) creado = fields.Boolean(u'Creado', default=False) med_cod_id = fields.Many2one('grp.sice_medida', string=u'Medida de la variante') pres_id = fields.Many2one('grp.sice_presentacion', string='Presentacion') med_cod_pres_id = fields.Many2one('grp.sice_medida', string=u'Medida de la presentación') det_variante_id = fields.Many2one('grp.sice_det_variante', string='Detalle de variante') sice_color_id = fields.Many2one('grp.sice_color', string='Color SICE') atributo_id = fields.Many2one('product.attribute', string='Atributo') valor_id = fields.Many2one('product.attribute.value', string='Valor atributo') atributo_name = fields.Char(string=u'Atributo') valor_name = fields.Char(string=u'Valor atributo') med_cod_desc = fields.Char(string=u'Medida variante') pres_desc = fields.Char(string=u'Presentación') med_cod_pres_desc = fields.Char(string=u'Medida presentación') det_variante_desc = fields.Char(string=u'Detalle variante') sice_color_desc = fields.Char(string=u'Color') marca_desc = fields.Char(string=u'Marca')
class GolDocument(osv.Model): _name = 'gol.document' _description = u'descripcion modulo' #Decalaracion de campos authorizationNumber = fields.Char('Número de Autorización') documentType = fields.Many2one('gol.document.type', 'Tipo de Documento') correlativeFrom = fields.Char('Correlativo Desde') correlativeTo = fields.Char('Correlativo Hasta') broadcastDate = fields.Date('Fecha Desde') expirationDate = fields.Date('Fecha Hasta') correlativeCurrentPosition = fields.Char('Posición Actual') active = fields.Boolean('Activo', default=True) #description=fields.Text('Descripción') correlativeLength = fields.Integer('Longitud') idPointOfSale = fields.Many2one('gol.point.of.sale', 'Punto de Venta')
class wizard_total_calculation_o2m(models.Model): _name = 'wizard.total.calculate.o2m' sidd_challenge_2 = fields.Many2one('student.student', 'Name') paid_fees = fields.Integer('Paid Fees:') amount_due = fields.Integer('Amount Due:') month_name = fields.Char('Month Name:')
class EmailMessage(models.Model): _name = 'test_new_api.emailmessage' _inherits = {'test_new_api.message': 'message'} message = fields.Many2one('test_new_api.message', 'Message', required=True, ondelete='cascade') email_to = fields.Char('To')
class subject(models.Model): _name = 'subject' name = fields.Char('Name', required=1) lectures_required = fields.Integer('Lectures Required') teacher_ids = fields.Many2many('teacher', 'teacher_subject_rel', 'subject_id', 'teacher_id', 'Teachers')
class Discussion(models.Model): _name = 'test_new_api.discussion' name = fields.Char( string='Title', required=True, help="General description of what this discussion is about.") moderator = fields.Many2one('res.users') categories = fields.Many2many('test_new_api.category', 'test_new_api_discussion_category', 'discussion', 'category') participants = fields.Many2many('res.users') messages = fields.One2many('test_new_api.message', 'discussion') message_concat = fields.Text(string='Message concatenate') important_messages = fields.One2many('test_new_api.message', 'discussion', domain=[('important', '=', True)]) @api.onchange('moderator') def _onchange_moderator(self): self.participants |= self.moderator @api.onchange('messages') def _onchange_messages(self): self.message_concat = "\n".join( ["%s:%s" % (m.name, m.body) for m in self.messages])