class citasmv(models.Model): _name = 'citasmv.citasmv' name = fields.char(string="Autor:", size=100, required=True), fecha = fields.date(string="Fecha de visualizaciòn:", required=True), description = fields.text(string="Descripciòn de la cita:", size=256, required=True), orden = fields.integer(string="Orden de visualizaciòn:", required=True)
class HrEmployee(model.Model): """Inherit hr_employee to add date_start and to add yours childrens """ _inherit = "hr.employee" _columns = { 'date_start': fields.date('Date Start'), 'children_ids': fields.one2many('hr.children', 'employee_id', 'Childrens') }
def _starting_date_of_current_month(self): """ Returns starting date of ongoing month @author : Er.Vaidehi Vasani @last_updated_on : 5th Sep, 2018 """ today = fields.date.today() year = today.year month = today.month day = 1 starting_date_of_current_month = fields.date(year, month, day) return starting_date_of_current_month
def _get_days_in_current_period(self, date_to=False, start_year=False): """Get days at current period to compute payments' proportional part :param date_to: date to get the days :type date_to: str :param start_year: period start at 1 Jan :type start_year: boolean :return: number of days of the contract in current period :rtype: int """ date = date_to or fields.Date.today() contract_date = self.date_start if start_year: date_start = fields.date(date.year, 1, 1) if (contract_date - date_start).days > 0: date_start = contract_date return (date - date_start).days + 1 date_start = fields.date(contract_date.year, contract_date.month, contract_date.day) if (date - date_start).days < 0: date_start = fields.date(date.year - 1, contract_date.month, contract_date.day) return (date - date_start).days + 1
class StockContainer(models.Model): _inherit = "mail.thread" _name = "stock.container" _description = "Container" _order = "name desc" name = fields.Char(string='Container Name', default='/', copy=False, required=True, help='Name of the Container') load = fields.date(string='Loading Date', copy=False, required=False) sail = fields.Date(string='Sailing Date', copy=False, required=False) arrival = fields.date(string='Arrival Date', copy=False, required=False) picking_ids = fields.One2many('stock.picking', 'container_id', string='Pickings', help='Transfers Associated w/ Container') cbm = fields.float(compute='_container_cbm', store=True, string='CBM', copy=False, required=False) @api.model def create(self, vals): if vals.get('name', '/') == '/': vals['name'] = '/' return super(StockContainer, self).create(vals) @api.depends('picking_ids') def _container_cbm(self): for record in self: #record.cbm = sum(record.picking_ids.filtered(lamda r: r.state != 'cancel').mapped('cbm')) for transfer in record.picking_ids: container_cbm += transfer.product_id.volume record.cbm = container_cbm
class account_voucher_line(osv.osv): _inherit= 'account.voucher.line' _columns={ 'event_date': fields.date('Date Of Service'), 'patient_id': fields.many2one('patient', 'Patient/Client',), 'reference': fields.char('Reference', size=64, select=1), 'project_name_id':fields.many2one('project','Project'), } def default_get(self, cr, user, fields_list, context=None): vals = super(account_voucher_line, self).default_get(cr, user, fields_list,context=context) vals.update({ 'account_id':'', 'type':'' }) return vals
class VistaPrincipal(models.Model): _name = 'autos' nombre = fields.Char(string='Nombre del auto', help='Introduce el nombre del vehiculo') marca = fields.Many2one('autos.marca', string='Marca', help='Selecciona la marca del vehiculo') # Este campo nos sirve para crear una relacion con otra tabla modelo = fields.Char(string='Modelo') year_fabricante = fields.date(string='Fecha de fabicación') color = fields.Char(string=('Color')) kilomet = fields.Integer(string='Kilometraje') garanty = fields.Boolean(string='Garantia') transmision = fields.Selection([('1','Automatico'),('2','Standart'),('3','Surtido Rico')]string='Tipo de transmisión') puertas = fields.Integer(string='No. de Puertas') pasajeros = fields.Float(string='No. de Pasajeros') litros = fields.Float(string='Litros (Motor)') cilindros = fields.Integer(string='Cilindros') combustible = fields.Selection([('1','Electrico'),('2','Magna'),('3','Premium'),('4','Diesel')]string='Combustible') picture = fields.Binary()
class HrChildren(model.Model): """Class to add object of childrens to employee """ _name = "hr.children" _order = 'name' _columns = { 'name': fields.char('Name', size=64, required=True), 'date_of_birth': fields.date('Date of birth'), 'schooling': fields.selection([('elementary', 'Elementary'), ('high_school', 'High School'), ('preparatory', 'Preparatory'), ('university', 'University')], 'Schooling'), 'employee_id': fields.many2one('hr.employee', 'Employee') }
class expenses_deduction_from_account_voucher(models.TransientModel): _name = "expenses.deduction.from.account.voucher" _description = "Create Expenses Deduction" def _get_date_expense(self, cr, uid, context=None): if context is None: context = {} voucher_pool = self.pool.get('account.voucher') active_id = context and context.get('active_id', []) voucher = voucher_pool.browse(cr, uid, active_id, context) return voucher and voucher.date date_expense = fields.date('Expense Date', default=_get_date_expense) @api.multi def create_expenses_deduction(self): # trebuie sa citesc datele si sa intru in moul de creare data_pool = self.pool.get('ir.model.data') voucher_pool = self.pool.get('account.voucher') action_model, action_id = data_pool.get_object_reference( cr, uid, 'deltatech_expenses', "action_deltatech_expenses_deduction") action_pool = self.pool.get(action_model) action = action_pool.read(cr, uid, action_id, context=context) res_ids = context and context.get('active_ids', []) expenses_pool = self.pool.get('deltatech.expenses.deduction') for expense in self.browse(cr, uid, ids, context): date_expense = expense.date_expense expenses_id = expenses_pool.create(cr, uid, {'date_expense': date_expense}, context) voucher_ids = [] for voucher in voucher_pool.browse(cr, uid, res_ids, context): if not voucher.expenses_deduction_id: voucher_ids.append(voucher.id) voucher_pool.write(cr, uid, voucher_ids, {'expenses_deduction_id': expenses_id}, context) action['domain'] = "[('id','in', [" + str(expenses_id) + "])]" return action
def _default_max_date(self): today = fields.date.today() return fields.date(today.year, today.month, 1)