class res_users(osv.osv): _name = "res.users" _description = "Users" _inherit = "res.users" gov_id = fields.Many2one('govs.villages.gov', 'Gov', on_change="onchange_gov(gov_id)") city_id = fields.Many2one('govs.villages.city', 'City', on_change="onchange_city(city_id)") #place_id = fields.Many2one('donation.place','Place') @api.onchange('gov_id') def onchange_gov(self): res = {} if self.gov_id: res['domain'] = {'city_id': [('gov_id', '=', self.gov_id.id)]} return res @api.onchange('city_id') def onchange_city(self): res = {} if self.city_id: res['domain'] = {'village_id': [('city_id', '=', self.city_id.id)]} return res
class GolCreditNote(osv.Model): _name = 'gol.credit.note' _description = u'descripcion modulo' #Decalaracion de campos documentType = fields.Many2one('gol.document.type', 'Tipo de Documento') correlative = fields.Char('Correlativo', required=False) date = fields.Date('Fecha', default=datetime.now().strftime('%Y-%m-%d')) #date=fields.Datetime('Fecha',default=datetime.now()) state = fields.Selection([('active', 'Activo'), ('annulled', 'Anulado')], 'Estado del Comprobante', default='active', required=True) invoice = fields.Many2one('account.invoice', 'Factura') authorizationNumber = fields.Char('Número de Autorización') typeCreditNote = fields.Many2one('gol.type.debit.note', 'Tipo') accountingVoucher = fields.One2many('account.move', 'idAccountMove', 'Comprobantes Contables') creditNoteAmount = fields.Float('Monto') taxAmount = fields.Float('Monto Impuesto') gloss = fields.Text('Glosa') #Campos Temporales Factura authorizationNumberInvoice = fields.Char( 'Número de Autorización de la Factura', Store=False) numberInvoice = fields.Char('Número de Factura', Store=False) estateInvoice = fields.Char('Estado', Store=False) amountInvoice = fields.Char('Monto Factura', Store=False) @api.onchange('invoice') def GetDatasInvoiceAndCustomer(self): self.authorizationNumberInvoice = self.invoice.authorizationNumber #self.numberInvoice=self.invoice.number self.estateInvoice = self.invoice.state
class res_partner(models.Model): _name = 'res.partner' _inherit = ['res.partner'] name = fields.Char('Name', required=True, select=True,track_visibility='onchange',) ref = fields.Char('Contact Reference', select=1,track_visibility='onchange',) bank_ids = fields.One2many('res.partner.bank', 'partner_id', string='Banks', track_visibility='onchange',) website = fields.Char('Website', track_visibility='onchange', help="Website of Partner or Company") comment = fields.Text('Notes', track_visibility='onchange',) active = fields.Boolean('Active', track_visibility='onchange',) function = fields.Char('Job Position',track_visibility='onchange',) type = fields.Selection([('default', 'Default'), ('invoice', 'Invoice'), ('delivery', 'Shipping'), ('contact', 'Contact'), ('other', 'Other')], 'Address Type',track_visibility='onchange', help="Used to select automatically the right address according to the context in sales and purchases documents.") street = fields.Char('Street',track_visibility='onchange',) street2 = fields.Char('Street2',track_visibility='onchange',) zip = fields.Char('Zip', size=24,track_visibility='onchange', change_default=True) city = fields.Char('City',track_visibility='onchange',) state_id = fields.Many2one("res.country.state", string='State', track_visibility='onchange',ondelete='restrict') country_id = fields.Many2one('res.country', string='Country',track_visibility='onchange', ondelete='restrict') email = fields.Char('Email',track_visibility='onchange',) phone = fields.Char('Phone',track_visibility='onchange',) fax = fields.Char('Fax',track_visibility='onchange',) mobile = fields.Char('Mobile',track_visibility='onchange',) # birthdate = fields.Char('Birthdate',track_visibility='onchange',) is_company = fields.Boolean('Is a Company', track_visibility='onchange',help="Check if the contact is a company, otherwise it is a person") use_parent_address = fields.Boolean('Use Company Address', track_visibility='onchange',help="Select this if you want to set company's address information for this contact") company_id = fields.Many2one('res.company', string='Company', track_visibility='onchange',select=1) user_ids = fields.One2many('res.users', 'partner_id', string='Users')
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 sale_order_line(models.Model): _inherit = 'sale.order.line' shipping_address_id = fields.Many2one('res.partner', string="Shipping Address") carrier_id_by_line = fields.Many2one('delivery.carrier', string="Delivery Method")
class GolOrganizerAccount(osv.Model): _name = 'gol.organizer.account' _inherit = 'gol.basic.entity' _description = u'descripcion modulo' type = fields.Selection([('totalizer', 'Totalizadora'), ('movement', 'Movimiento')], 'Tipo Interno', default='movement', required=True) fatherAccount = fields.Many2one('gol.organizer.account', 'Cuenta Padre') classifier = fields.Many2one('gol.classifier', 'Clasificador de Cuenta') accountType = fields.Many2one('account.account.type', 'Tipo Cuenta') description = fields.Text('Descripción u Observación') organizerType = fields.Many2one('gol.organizer.type', 'Tipo Ordenador') _sql_constraints = [ ('ValidateAccountUnduplicated', 'unique(code)', 'El código de la Cuenta Tipo Ordenador a ser ingresado existe, ingrese una nueva' ), ] @api.model def create(self, vals): rec = super(GolOrganizerAccount, self).create(vals) if (rec.fatherAccount.code is not False): rec.code = str(rec.fatherAccount.code) + '.' + rec.code # ... return rec
class account_invoice_line(models.Model): _inherit = 'account.invoice.line' sale_office_id = fields.Many2one('sale.office', string='Sales Office') profit_center_id = fields.Many2one('profit.center', string='Profit Center') wbs_project_id = fields.Many2one('wbs.project', string='WBS/Project') @api.model def move_line_get_item(self, line): return { 'type': 'src', 'name': line.name.split('\n')[0][:64], 'price_unit': line.price_unit, 'quantity': line.quantity, 'price': line.price_subtotal, 'account_id': line.account_id.id, 'product_id': line.product_id.id, 'uos_id': line.uos_id.id, 'account_analytic_id': line.account_analytic_id.id, 'taxes': line.invoice_line_tax_id, # Org Dimension 'business_area_id': line.invoice_id.business_area_id.id, 'sale_office_id': line.sale_office_id.id, 'profit_center_id': line.profit_center_id.id, 'wbs_project_id': line.wbs_project_id.id, }
class wizard_declaration_fiscal(models.TransientModel): _name = 'declaration_fiscale.declaration_fiscal' fiscalyear_id = fields.Many2one('account.fiscalyear', string='Exercice fiscal', required=True, help="entrer ici l'année fiscale") periode = fields.Many2one('account.period', string='Période', required=True, help="entrer les methodes ici") sum_vnt_loc = fields.Integer( required=True, string='Somme des ventes locale', help="ici en va entrer la somme des vente locales") sum_vnt_ext = fields.Integer( required=True, string='Somme des ventes export', help="ici en va entrer la somme des ventes distant") @api.v7 def print_report(self, cr, uid, ids, context=None): datas = {'ids': context.get('active_ids', [])} datas['model'] = False datas['form'] = self.read(cr, uid, ids, context=context)[0] return { 'type': 'ir.actions.report.xml', 'report_name': 'declaration_fiscale.declaration_fiscal_report', 'datas': datas, 'name': u'Rapport de declaration Fiscal', 'context': context }
class subjects(models.Model): _name = 'subject' _rec_name = 'subject' select_student = fields.Many2one('student','Select Student:') subject = fields.Char('Title : ') subject1 = fields.Integer('Physics: ') subject2 = fields.Integer('Chemistry: ') subject3 = fields.Integer('Maths: ') percentage = fields.Float('Percentage:') choose_teacher = fields.Many2one('teacher','Choose Teacher :') teacher_expense = fields.Integer('Teacher fees Expected: ') tution_fees = fields.Integer('Tution Fees :') travel_expense = fields.Integer('Travel Expense: ') @api.multi @api.onchange('teacher_expense') def calculation(self): self.tution_fees = self.teacher_expense + 2000 self.travel_expense = self.tution_fees - 1000 @api.multi @api.onchange('percentage','subject1','subject2','subject3') def calculate(self): total = 300 total_marks = self.subject1 + self.subject2 + self.subject3 self.percentage = (total_marks * 100) / total
class StockPicking(models.Model): _inherit = 'stock.picking' ntransfer_type = fields.Selection( selection_add=[('rm_virtual', 'Raw at Virtual'), ('rm_production', 'RM at Produciton')]) material_request_id = fields.Many2one('mrp.raw.material.request', 'Request No.') rm_picking_ids = fields.Many2many('mrp.production.workcenter.line', 'wo_raw_material_picking_rel', 'picking_id', 'wo_id', 'Delivery No.', help="Receive Raw Material Delivery no.") next_prev_picking_id = fields.Many2many( 'stock.picking', 'next_previous_rm_picking_rel', 'next_id', 'prev_id', 'Delivery No.', help="Shows next and previous delivery number") rm_received_emp = fields.Many2one('hr.employee', 'Received By') '''@api.multi
class GolCustomer(osv.Model): _name = 'res.partner' _inherit = 'res.partner' comment=fields.Text("Descripción u Observación") tradename=fields.Char('Nombre Comercial', size=80) phone=fields.Char('Teléfono 1', size=15) 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) #Datos del cliente shortName=fields.Char('Nombre Corto', size=80) customerType=fields.Many2one('gol.customer.type','Tipo de Cliente') #accountingAccount=fields.Many2one('account.account','Cuenta Contable') balance=fields.Float('Saldo') customerType=fields.Many2one('gol.customer.type','Tipo de Cliente') discount=fields.Many2one('gol.generic.discount','Descuento Cliente') rulesRetention=fields.One2many('gol.validator.retention','idRulesRetention','Reglas Retención') #Campos para el Credito maximunAmount=fields.Float('Monto Maximo',size=50,help='Monto maximo de crédito') warranty=fields.Text('Garantía',help='Que tiene de garantia por el crédito')
class respartnerHistorico(models.Model): _name = "res.partner.historico" alumno_id = fields.Many2one('res.partner', string="Alumno") usuario_id = fields.Many2one('res.users', string="Usuario", default=lambda self: self.env.user, readonly=True) enero = fields.Boolean(string="Enero") febrero = fields.Boolean(string="Febrero") marzo = fields.Boolean(string="Marzo") abril = fields.Boolean(string="Abril") mayo = fields.Boolean(string="Mayo") junio = fields.Boolean(string="Junio") julio = fields.Boolean(string="Julio") agosto = fields.Boolean(string="Agosto") septiembre = fields.Boolean(string="Septiembre") octubre = fields.Boolean(string="Octubre") noviembre = fields.Boolean(string="Noviembre") diciembre = fields.Boolean(string="Diciembre") accion = fields.Selection( (('0', 'Ninguno'), ('1', 'Facturar'), ('2', 'Cobrar')), 'Acción', required=False, default='0')
class vetclinic_animalvaccination(models.Model): _name = 'vetclinic.animalvaccination' products_id = fields.Many2one('product.product', 'Vaccination:') duedate = fields.Date('Due Date:') dateperfomed = fields.Date('Date Performed:') animal_id = fields.Many2one('vetclinic.animal', 'Animal:')
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 od_hr_job_line(models.Model): _name = 'od.hr.job.line' employee_id = fields.Many2one('hr.employee', string='Employee') date_from = fields.Date(String='Date From') date_to = fields.Date(String='Date To') job_id = fields.Many2one('hr.job', string='Job Title') name = fields.Text(string='Responsibility')
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 descuentos_factura_escuela(models.Model): _name = "descuentos.factura" descuento_id = fields.Many2one('descuentos', 'Descuento') monto = fields.Float(string='Total') factura_id = fields.Many2one('account.invoice', 'Facturas', ondelete="cascade")
class born_spread_limit_product(osv.osv): _name = 'born.spread.limit.product' product_id = fields.Many2one( 'product.product', u'产品', ) spread_id = fields.Many2one("born.spread", u'活动')
class GolConsecutiveTypeAccountingVoucher(osv.Model): _name = 'gol.consecutive' #Decalaracion de campos typeVoucher=fields.Many2one('gol.type.voucher','Tipo de Comprobante',required=True) cosecutive=fields.Char('Consecutivo',size=50,readonly=True,help='Posicion del consecutivo mas 1') mont=fields.Boolean('Mes',default=True,help='Permite agrupar los consecutivos en funcion de mes') year=fields.Boolean('Año',default=True,help='Permite agrupar los consecutivos en funcion de año') idFormatCorrelative=fields.Many2one('gol.format.correlative','Formato Correlativo')
class descuentos_tomar_escuela(models.Model): _name = "descuentos.tomar" sequence = fields.Integer('Sequence') descuento_id = fields.Many2one('descuentos', 'Descuento') porcentaje = fields.Float(related='descuento_id.porcentaje', string='Porcentaje') partner_ids = fields.Many2one('res.partner', 'Alumno', ondelete="cascade")
class res_kecamatan(models.Model): _name = "res.kecamatan" _description = "List Kecamatan" name = fields.Char(string='Kecamatan') state_id = fields.Many2one('res.country.state', string="Province") kabupaten_id = fields.Many2one('res.kabupaten', string="Kabupaten") kelurahan_line = fields.One2many('res.kelurahan', 'kecamatan_id', string='Kelurahan')
class od_leave_on_particular_period_report(models.Model): _name = 'od.leave.on.particular.period.report' _description = "od.leave.on.particular.period.report" employee_id = fields.Many2one('hr.employee',string='Employee') holiday_status_id = fields.Many2one('hr.holidays.status',string='Leave Type',) from_date = fields.Datetime(string='From Date') to_date = fields.Datetime(string='To Date') state = fields.Char('state')
class account_voucher_detalle(models.Model): _name = "account.voucher.detalle" voucher_id =fields.Many2one('res.partner',string="Relacion") usuario_id=fields.Many2one('res.users',string="Usuario", default=lambda self:self.env.user ,readonly=True) company_id = fields.Many2one(related='usuario_id.company_id',string="Compañia") res_partner_bank_id = fields.Many2one('res.partner.bank',string="Banco Fuente")#,domain="[('company_id', '=', company_id)]") codigo_proveedor = fields.Char(string="Codigo Proveedor",size=16)
class od_hr_employee_launguage_line(models.Model): _name = 'od.hr.employee.launguage.line' _description = "od.hr.employee.launguage.line" employee_id = fields.Many2one('hr.employee', string='Employee') launguage_id = fields.Many2one('res.lang', string='Launguage') speak = fields.Boolean(string='Speak', default=False) writes = fields.Boolean(string='Write', default=False) reads = fields.Boolean(string='Read', default=False)
class GolItemCenterCost(osv.Model): _name = 'gol.item.center.cost' _description = u'descripcion modulo' centerCost=fields.Many2one('gol.center.cost','Centro de costo') value=fields.Float('Valor (%)') #Decalaracion de campos idItemCenterCost=fields.Many2one('gol.apportionment','Tabla de Prorrateo')
class maintenace_failure_report(osv.osv): _name = "maintenance.failure.report" _description = "Maintenance Failure Analysis" _auto = False name = fields.Char('Year', required=False, readonly=True) brand = fields.Many2one('maintenance.element.brand', 'Brand', readonly=True) intervention_id = fields.Many2one('maintenance.intervention', 'Intervention', readonly=True) nbr = fields.Integer('# of Interventions', readonly=True) date_start = fields.Datetime('Start Date', readonly=True) date_end = fields.Datetime('End Date', readonly=True) effective_duration = fields.Datetime('Effective Duration') failure_type_id = fields.Many2one('maintenance.failure.type', 'Failure Type', readonly=True) failure_element_id = fields.Many2one('maintenance.element', 'Element damaged', readonly=True) partner_id = fields.Many2one('res.partner', 'Partner', readonly=True) time_planned = fields.Float('Time Planned', readonly=True) def init(self, cr): tools.sql.drop_view_if_exists(cr, 'maintenance_failure_report') cr.execute(""" CREATE view maintenance_failure_report as SELECT (select 1 ) AS nbr, i.id as id, i.id as intervention_id, i.date_start as date_start, i.date_end as date_end, (DATE_PART('day', MAX(mit.date_end)::timestamp - i.date_start::timestamp) * 24 + DATE_PART('hour', MAX(mit.date_end)::timestamp - i.date_start::timestamp)) as effective_duration, i.time_planned, i.installation_id, i.failure_type_id, i.failure_element_id, me.brand, mi.partner_id FROM maintenance_intervention i JOIN maintenance_installation mi ON i.installation_id = mi.id JOIN maintenance_intervention_task mit ON i.id = mit.intervention_id JOIN maintenance_element me ON me.id = i.failure_element_id GROUP BY i.id, i.date_start, i.date_end, time_planned, i.installation_id, failure_type_id, failure_element_id, me.brand, mi.partner_id """)
class invoices_analysis_wizard_lines(models.TransientModel): """ For Reporte kardex valorado """ _name = "invoices.analysis.wizard.lines" _description = "Invoices analysis Wizard Lines" wizard_id = fields.Many2one('invoices.analysis.wizard', 'Wizard') product_id = fields.Many2one('product.product', string='Product')
class report_kardex_wizard_lines(models.TransientModel): """ For Reporte kardex valorado """ _name = "pos.order.analysis.wizard.lines" _description = "POS order analysis Wizard Lines" wizard_id = fields.Many2one('pos.order.analysis.wizard', 'Wizard') product_id = fields.Many2one('product.product', string='Product')
class machine_piece_rel(models.Model): _name = "machine.piece.rel" piece_id = fields.Many2one('maintenance.piece', 'Piéce', ondelete='cascade') machine_id = fields.Many2one('production.machine', 'Machine', ondelete='cascade')
class Configuracion(models.Model): _name = "configuracion" id_pais = fields.Many2one('res.country', string="País") id_provincia = fields.Many2one('res.country.state', string="Provincia") dias_pago = fields.Integer(string="Cantidad de dias para pronto pago") ciudad = fields.Char(string='Ciudad') cuenta_id_default = fields.Many2one('fiscal.tipodocumento', string="Tipo de Documento Por Defecto")