class WizardCustomerPer(osv.TransientModel): _name = 'wiz.customer.performance' _description = 'Generate Report for Customer Performance' _columns = { 'start_date': fields.date('Start Date', required=True), 'end_date': fields.date('End Date', required=True), 'partner_id': fields.many2many('res.partner', string='Customer', required=True), 'journal': fields.many2many('account.journal', string='Bank') } def fetch_record(self, journal_id): self.env.cr.execute("""SELECT aml.partner_id,rp.name,SUM(credit) AS amount FROM account_move_line as aml INNER JOIN res_partner as rp ON aml.partner_id=rp.id where journal_id = %s and partner_id in %s and aml.date between '%s' AND '%s' group by aml.partner_id,rp.name order by rp.name""" %(journal_id,tuple(self.partner_id.ids) if len(self.partner_id.ids)>1 else "("+str(self.partner_id.ids[0])+")",self.start_date,self.end_date)) products = self.env.cr.dictfetchall() return products def get_partner_name(self,partner_id): partner_name = self.env['res.partner'].search(([('id', '=', partner_id)])) return partner_name[0].name # # def get_journal_name(self,journal): # journal_name = self.env['account.journal'].search(([('id', '=', journal)])) # return journal_name[0].name def print_report(self, cr, uid, ids, data, context=None): return { 'type': 'ir.actions.report.xml', 'name': 'oc_mutual_customization.report_customer_recov_template', 'report_name': 'oc_mutual_customization.report_customer_recov_template' }
class hr_accrual_job(models.Model): _name = 'hr.policy.line.accrual.job' _description = 'Accrual Policy Line Job Run' _columns = { 'name': fields.date('Date', required=True, readonly=True), 'exec': fields.datetime('Execution Date/Time', required=True, readonly=True), 'policy_line_id': fields.many2one('hr.policy.line.accrual', 'Accrual Policy Line', required=True, readonly=True), 'accrual_line_ids': fields.many2many('hr.accrual.line', 'hr_policy_job_accrual_line_rel', 'job_id', 'accrual_line_id', 'Accrual Lines', readonly=True), 'holiday_ids': fields.many2many('hr.holidays', 'hr_policy_job_holiday_rel', 'job_id', 'holiday_id', 'Leave Allocation Requests', readonly=True), }
class init_wage(models.Model): _name = 'hr.contract.init.wage' _description = 'Starting Wages' _columns = { 'job_id': fields.many2one( 'hr.job', 'Job', ), 'starting_wage': fields.float('Starting Wage', digits_compute=dp.get_precision('Payroll'), required=True), 'is_default': fields.boolean( 'Use as Default', help="Use as default wage", ), 'contract_init_id': fields.many2one( 'hr.contract.init', 'Contract Settings', ), 'category_ids': fields.many2many( 'hr.employee.category', 'contract_init_category_rel', 'contract_init_id', 'category_id', 'Tags', ), } def _rec_message(self, cr, uid, ids, context=None): return _('A Job Position cannot be referenced more than once in a ' 'Contract Settings record.') _sql_constraints = [ ('unique_job_cinit', 'UNIQUE(job_id,contract_init_id)', _rec_message), ] def unlink(self, cr, uid, ids, context=None): if isinstance(ids, (int, long)): ids = [ids] data = self.read(cr, uid, ids, ['contract_init_id'], context=context) for d in data: if not d.get('contract_init_id', False): continue d2 = self.pool.get('hr.contract.init').read( cr, uid, d['contract_init_id'][0], ['state'], context=context) if d2['state'] in ['approve', 'decline']: raise models.except_orm( _('Error'), _('You may not a delete a record that is not in a ' '"Draft" state')) return super(init_wage, self).unlink(cr, uid, ids, context=context)
class medical_patient(osv.osv): _name = "medical.patient" _inherit = "medical.patient" _columns = { 'surgery': fields.many2many('medical.surgery', 'patient_surgery_rel', 'patient_id', 'surgery_id', 'Surgeries'), }
class wolftrakglobal_report_608(osv.osv): _name = 'wolftrakglobal.report608' _columns = { 'invoices': fields.many2many('account.invoice', domain=[('type', '=', 'out_refund'), ('company_id', '=', 3)], string="Facturas"), 'desde_608': fields.date('Desde:'), 'desde_str': fields.char(compute='_toma_desde'), 'hasta_608': fields.date('Hasta:'), 'hasta_str': fields.char(compute='_toma_hasta'), 'periodo': fields.char(compute='_toma_periodo', readonly=True, string='Periodo'), 'cant_reg': fields.integer('Cantidad de registros') } _defaults = { 'desde_608': lambda *a: time.strftime('%Y-%m-01'), 'hasta_608': lambda *a: str(datetime.now() + relativedelta.relativedelta( months=+1, day=1, days=-1))[:10], } @api.onchange('invoices') def _toma_registro(self): for value in self.invoices: self.cant_reg = len(self.invoices) @api.depends('hasta_608') def _toma_periodo(self): month = str(self.hasta_608[5:7]) year = str(self.hasta_608[:4]) self.periodo = year + month @api.depends('desde_608') def _toma_desde(self): year = str(self.desde_608[:4]) month = str(self.desde_608[5:7]) day = str(self.desde_608[8:10]) self.desde_str = year + month + day @api.depends('hasta_608') def _toma_hasta(self): year = str(self.hasta_608[:4]) month = str(self.hasta_608[5:7]) day = str(self.hasta_608[8:10]) self.hasta_str = year + month + day
class account_invoice(models.Model): _inherit = 'account.invoice' # This is the reverse link of the field 'invoice_ids' of sale.order # defined in addons/sale/sale.py sale_ids = fields.many2many( 'sale.order', 'sale_order_invoice_rel', 'invoice_id', 'order_id', 'Sale Orders', readonly=True, help="This is the list of sale orders related to this invoice.")
class policy_group(models.Model): _name = 'hr.policy.group' _inherit = 'hr.policy.group' _columns = { 'accr_policy_ids': fields.many2many('hr.policy.accrual', 'hr_policy_group_accr_rel', 'group_id', 'accr_id', 'Accrual Policy'), }
class policy_group(models.Model): _name = 'hr.policy.group' _inherit = 'hr.policy.group' _columns = { 'presence_policy_ids': fields.many2many('hr.policy.presence', 'hr_policy_group_presence_rel', 'group_id', 'presence_id', 'Presence Policy'), }
class policy_group(models.Model): _name = 'hr.policy.group' _inherit = 'hr.policy.group' _columns = { 'ot_policy_ids': fields.many2many( 'hr.policy.ot', 'hr_policy_group_ot_rel', 'group_id', 'ot_id', 'Overtime Policy'), }
class department_selection(models.TransientModel): _name = 'hr.schedule.validate.departments' _description = 'Department Selection for Validation' _columns = { 'department_ids': fields.many2many( 'hr.department', 'hr_department_group_rel', 'employee_id', 'department_id', 'Departments', ), } def view_schedules(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids, context=context)[0] return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'hr.schedule', 'domain': [ ('department_id', 'in', data['department_ids']), ('state', 'in', ['draft']), ], 'type': 'ir.actions.act_window', 'target': 'new', 'nodestroy': True, 'context': context, } def do_validate(self, cr, uid, ids, context=None): wkf_service = netsvc.LocalService('workflow') data = self.read(cr, uid, ids, context=context)[0] sched_ids = self.pool.get('hr.schedule').search( cr, uid, [('department_id', 'in', data['department_ids'])], context=context) for sched_id in sched_ids: wkf_service.trg_validate(uid, 'hr.schedule', sched_id, 'signal_validate', cr) return {'type': 'ir.actions.act_window_close'}
class tipo_libro(osv.osv): _name="tipo.libro" _description = 'tipo de libro' _columns = { 'name': fields.char('Genero', size=64, readonly=False), #RELACION MUCHOS A MUCHOS CON LA TABLA BIBLIOTECA.LIBRO 'tipo_id': fields.many2many('biblioteca.libro', id1="tipo_id", id2="libro_id", string="tipo de libro") }
class biblioteca_libro(osv.osv): _name = 'biblioteca.libro' _description = 'biblioteca' _columns = { #'libros_id': fields.many2one('tipo.libro', string="tipo de libro", # required=True, select=True, RELACION MUCHOS A UNO # help='Tipo de libro', store=True ), #RELACION MUCHOS A MUCHOS CON LA TABLA TIPO.LIBRO 'tipos_id': fields.many2many('tipo.libro', 'tipo_libro_rel', id1='libro_id', id2='tipo_id', string="tipo de libro"), 'prestamo_id': fields.many2one('prestamo.libro', string="prestamo de libro",required=False, select=True, store=True), 'name':fields.char('nombre', size=64, required=False, readonly=False), 'description': fields.text('Description'), 'date': fields.date('fecha publicacion'), 'autor':fields.char('autor', size=64, required=False, readonly=False), 'cantidad':fields.integer('numero de libros disponibles', required=True, store=True), } _defaults = { 'prestamo_id': "no hay prestamos" } @api.onchange('prestamo_id') # indicamos los campos que van a cambiar def _onchange_edad(self): self.cantidad = self.cantidad -1
class wolftrak_report_609(osv.osv): _name = 'wolftrakglobal.report609' _columns = { 'invoices': fields.many2many('account.invoice', domain=[('type', '=', 'in_invoice'), ('company_id', '=', 3)]), 'desde_609': fields.date('Desde:'), 'desde_str': fields.char(compute='_toma_desde'), 'hasta_609': fields.date('Hasta:'), 'hasta_str': fields.char(compute='_toma_hasta'), 'periodo': fields.char(compute='_toma_periodo', readonly=True, string='Periodo'), 'cant_reg': fields.integer('Cantidad de registros'), 'total_cld': fields.float('Total monto facturado'), 'total_isr': fields.float('Total ISR Retenido') } _defaults = { 'desde_609': lambda *a: time.strftime('%Y-%m-01'), 'hasta_609': lambda *a: str(datetime.now() + relativedelta.relativedelta( months=+1, day=1, days=-1))[:10], } @api.onchange('invoices') def _toma_registro(self): for value in self.invoices: self.cant_reg = len(self.invoices) @api.depends('hasta_609') def _toma_periodo(self): month = str(self.hasta_609[5:7]) year = str(self.hasta_609[:4]) self.periodo = year + month @api.depends('desde_609') def _toma_desde(self): year = str(self.desde_609[:4]) month = str(self.desde_609[5:7]) day = str(self.desde_609[8:10]) self.desde_str = year + month + day @api.depends('hasta_609') def _toma_hasta(self): year = str(self.hasta_609[:4]) month = str(self.hasta_609[5:7]) day = str(self.hasta_609[8:10]) self.hasta_str = year + month + day @api.onchange('invoices') def total_calculado(self): self.total_cld = 0.0 self.total_isr = 0.0 for value in self.invoices: self.total_cld += value.amount_total self.total_isr += value.isr_hold
class report_vat_invoices(osv.osv): """ Print tax from invoice """ _name = "report.vat.invoices" _description = "Print tax report" _columns = { 'name': fields.char(size=256, string="Name", required="True"), 'date_start': fields.date(required="True"), 'date_end': fields.date(required="True"), 'company_id': fields.many2one('res.company', string="Company"), 'invoices_id': fields.many2many('account.invoice', string="Invoices"), 'tax_27': fields.float(computed="get_vat_amount"), 'tax_21': fields.float(computed="get_vat_amount"), 'tax_105': fields.float(computed="get_vat_amount"), 'total_vat_sale': fields.float(computed="get_vat_sale"), 'total_vat_purchase': fields.float(computed="_get_vat_purchase"), 'total_vat_nc': fields.float(computed="_get_vat_nc"), 'amount_vat': fields.float(computed="_get_vat_amount"), } @api.multi def get_vat_amount(self): self.tax_27 = self._get_vat_27() self.tax_21 = self._get_vat_21() self.tax_105 = self._get_vat_105() self.total_vat_purchase = self._get_vat_purchase() self.total_vat_sale = self._get_vat_sale() self.total_vat_nc = self._get_vat_nc() self.amount_vat = self.tax_27 + self.tax_21 + self.tax_105 def _get_vat_purchase(self): vat_purchase = 0.0 for record in self.invoices_id: if record.type == "in_invoice": vat_purchase -= record.amount_tax return vat_purchase def _get_vat_nc(self): vat_nc = 0.0 for record in self.invoices_id: if record.type == "out_refund": vat_nc -= record.amount_tax elif record.type == 'in_refund': vat_nc += record.amount_tax return vat_nc def _get_vat_sale(self): vat_sale = 0.0 for record in self.invoices_id: if record.type == "out_invoice": vat_sale += record.amount_tax return vat_sale def _get_vat_27(self): tax_27 = 0 for record in self.invoices_id: for tax_list in record.tax_line: if tax_list.name == '01003006:V': tax_27 += tax_list.amount elif tax_list.name == '01003006:C': tax_27 -= tax_list.amount return tax_27 def _get_vat_21(self): tax_21 = 0.0 for record in self.invoices_id: for tax_list in record.tax_line: if tax_list.name == '01003005:V': tax_21 += tax_list.amount elif tax_list.name == '01003005:C': tax_21 -= tax_list.amount return tax_21 def _get_vat_105(self): tax_105 = 0.0 for record in self.invoices_id: for tax_list in record.tax_line: if tax_list.name == '01003004:V': tax_105 += tax_list.amount elif tax_list.name == '01003004:C': tax_105 -= tax_list.amount return tax_105 @api.multi def fill_invoices_list(self): list_of_invoices = self.env['account.invoice'].search([ ('&'), ('date_invoice', '>=', self.date_start), ('date_invoice', '<=', self.date_end), ('state', '!=', 'draft'), ('state', '!=', 'cancel') ]) list_of_ids = [] for l_invoices in list_of_invoices: list_of_ids.append(l_invoices.id) self.write({'invoices_id': [(6, 0, list_of_ids)]})
class wolftrakglobal_report(osv.osv): _name = 'wolftrakglobal.report607' _columns = { 'desde_607': fields.date('Desde:'), 'desde_str': fields.char(compute='_toma_desde'), 'hasta_607': fields.date('Hasta:'), 'hasta_str': fields.char(compute='_toma_hasta'), 'total_cld': fields.float('Total Calculado: '), 'total_tax': fields.float('ITBIS Calculado: '), 'reporte': fields.many2many('account.invoice', 'name', 'amount_untaxed', 'amount_tax', string='Entradas: ', domain=[('type', '=', 'out_invoice'), ('state', '!=', 'draft'), ('company_id', '=', 3)]), 'periodo': fields.char(compute='_toma_periodo', string='Periodo', readonly=True), 'cant_reg': fields.integer('Cantidad de registros') } _defaults = { 'desde_607': lambda *a: time.strftime('%Y-%m-01'), 'hasta_607': lambda *a: str(datetime.now() + relativedelta.relativedelta( months=+1, day=1, days=-1))[:10], } @api.onchange('reporte') def total_calculado(self): self.total_cld = 0.0 self.total_tax = 0.0 for value in self.reporte: self.total_cld += value.amount_untaxed self.total_tax += value.amount_tax self.cant_reg = len(self.reporte) @api.depends('hasta_607') def _toma_periodo(self): month = str(self.hasta_607[5:7]) year = str(self.hasta_607[:4]) self.periodo = year + month @api.depends('desde_607') def _toma_desde(self): year = str(self.desde_607[:4]) month = str(self.desde_607[5:7]) day = str(self.desde_607[8:10]) self.desde_str = year + month + day @api.depends('hasta_607') def _toma_hasta(self): year = str(self.hasta_607[:4]) month = str(self.hasta_607[5:7]) day = str(self.hasta_607[8:10]) self.hasta_str = year + month + day
class WizardReport(models.TransientModel): _name = "wizard.report" _columns = { 'afr_id': fields.many2one( 'afr', 'Custom Report', help='If you have already set a Custom Report, Select it Here.'), 'company_id': fields.many2one('res.company', 'Company', required=True), 'currency_id': fields.many2one( 'res.currency', 'Currency', help="Currency at which this report will be expressed. If not \ selected will be used the one set in the company"), 'inf_type': fields.selection([('BS', 'Balance Sheet'), ('IS', 'Income Statement')], 'Type', required=True), 'columns': fields.selection([('one', 'End. Balance'), ('two', 'Debit | Credit'), ('four', 'Initial | Debit | Credit | YTD'), ('five', 'Initial | Debit | Credit | Period | YTD'), ('qtr', "4 QTR's | YTD"), ('thirteen', '12 Months | YTD')], 'Columns', required=True), 'display_account': fields.selection([('all', 'All Accounts'), ('bal', 'With Balance'), ('mov', 'With movements'), ('bal_mov', 'With Balance / Movements')], 'Display accounts'), 'display_account_level': fields.integer( 'Up to level', help='Display accounts up to this level (0 to show all)'), 'account_list': fields.many2many('account.account', 'rel_wizard_account', 'account_list', 'account_id', 'Root accounts', required=True), 'fiscalyear': fields.many2one('account.fiscalyear', 'Fiscal year', help='Fiscal Year for this report', required=True), 'periods': fields.many2many('account.period', 'rel_wizard_period', 'wizard_id', 'period_id', 'Periods', help='All periods in the fiscal year if empty'), 'analytic_ledger': fields.boolean( 'Analytic Ledger', help="Allows to Generate an Analytic Ledger for accounts with \ moves. Available when Balance Sheet and 'Initial | Debit | Credit \ | YTD' are selected"), 'journal_ledger': fields.boolean( 'Journal Ledger', help="Allows to Generate an Journal Ledger for accounts with \ moves. Available when Balance Sheet and 'Initial | Debit | Credit \ | YTD' are selected"), 'partner_balance': fields.boolean( 'Partner Balance', help="Allows to Generate a Partner Balance for accounts with \ moves. Available when Balance Sheet and 'Initial | Debit | Credit \ | YTD' are selected"), 'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the \ end of the Report which will Summarize \ Columns in Report'), 'lab_str': fields.char('Description', help='Description for the Summary', size=128), 'target_move': fields.selection( [ ('posted', 'All Posted Entries'), ('all', 'All Entries'), ], 'Entries to Include', required=True, help='Print All Accounting Entries or just Posted Accounting \ Entries'), # ~ Deprecated fields 'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'), 'date_to': fields.date('End date'), 'date_from': fields.date('Start date'), } _defaults = { 'date_from': lambda *a: time.strftime('%Y-%m-%d'), 'date_to': lambda *a: time.strftime('%Y-%m-%d'), 'filter': lambda *a: 'byperiod', 'display_account_level': lambda *a: 0, 'inf_type': lambda *a: 'BS', 'company_id': lambda self, cr, uid, c: self.pool['res.company']._company_default_get( cr, uid, 'account.invoice', context=c), 'fiscalyear': lambda self, cr, uid, c: self.pool['account.fiscalyear'].find(cr, uid), 'display_account': lambda *a: 'bal_mov', 'columns': lambda *a: 'five', 'target_move': 'posted', } def onchange_inf_type(self, cr, uid, ids, inf_type, context=None): if context is None: context = {} res = {'value': {}} if inf_type != 'BS': res['value'].update({'analytic_ledger': False}) return res def onchange_columns(self, cr, uid, ids, columns, fiscalyear, periods, context=None): if context is None: context = {} res = {'value': {}} p_obj = self.pool.get("account.period") all_periods = p_obj.search(cr, uid, [('fiscalyear_id', '=', fiscalyear), ('special', '=', False)], context=context) s = set(periods[0][2]) t = set(all_periods) go = periods[0][2] and s.issubset(t) or False if columns != 'four': res['value'].update({'analytic_ledger': False}) if columns in ('qtr', 'thirteen'): res['value'].update({'periods': all_periods}) else: if go: res['value'].update({'periods': periods}) else: res['value'].update({'periods': []}) return res def onchange_analytic_ledger(self, cr, uid, ids, company_id, analytic_ledger, context=None): if context is None: context = {} context['company_id'] = company_id res = {'value': {}} cur_id = self.pool.get('res.company').browse( cr, uid, company_id, context=context).currency_id.id res['value'].update({'currency_id': cur_id}) return res def onchange_company_id(self, cr, uid, ids, company_id, context=None): if context is None: context = {} context['company_id'] = company_id res = {'value': {}} if not company_id: return res cur_id = self.pool.get('res.company').browse( cr, uid, company_id, context=context).currency_id.id fy_id = self.pool.get('account.fiscalyear').find(cr, uid, context=context) res['value'].update({'fiscalyear': fy_id}) res['value'].update({'currency_id': cur_id}) res['value'].update({'account_list': []}) res['value'].update({'periods': []}) res['value'].update({'afr_id': None}) return res def onchange_afr_id(self, cr, uid, ids, afr_id, context=None): if context is None: context = {} res = {'value': {}} if not afr_id: return res afr_brw = self.pool.get('afr').browse(cr, uid, afr_id, context=context) res['value'].update({ 'currency_id': afr_brw.currency_id and afr_brw.currency_id.id or afr_brw.company_id.currency_id.id, }) res['value'].update({'inf_type': afr_brw.inf_type or 'BS'}) res['value'].update({'columns': afr_brw.columns or 'five'}) res['value'].update({ 'display_account': afr_brw.display_account or 'bal_mov', }) res['value'].update( {'display_account_level': afr_brw.display_account_level or 0}) res['value'].update( {'fiscalyear': afr_brw.fiscalyear_id and afr_brw.fiscalyear_id.id}) res['value'].update( {'account_list': [acc.id for acc in afr_brw.account_ids]}) res['value'].update({'periods': [p.id for p in afr_brw.period_ids]}) res['value'].update( {'analytic_ledger': afr_brw.analytic_ledger or False}) res['value'].update({'tot_check': afr_brw.tot_check or False}) res['value'].update({ 'lab_str': afr_brw.lab_str or _('Write a Description for your Summary Total') }) return res def _get_defaults(self, cr, uid, data, context=None): if context is None: context = {} user = self.pool['res.users'].browse(cr, uid, uid, context=context) if user.company_id: company_id = user.company_id.id else: company_id = self.pool['res.company'].search( cr, uid, [('parent_id', '=', False)])[0] data['form']['company_id'] = company_id fiscalyear_obj = self.pool['account.fiscalyear'] data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) data['form']['context'] = context return data['form'] def _check_state(self, cr, uid, data, context=None): if context is None: context = {} if data['form']['filter'] == 'bydate': self._check_date(cr, uid, data, context) return data['form'] def _check_date(self, cr, uid, data, context=None): if context is None: context = {} if data['form']['date_from'] > data['form']['date_to']: raise osv.except_osv( _('Error !'), ('La fecha final debe ser mayor a la inicial')) sql = """SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f WHERE '%s' = f.id """ % (data['form']['fiscalyear']) cr.execute(sql) res = cr.dictfetchall() if res: if data['form']['date_to'] > res[0]['date_stop'] or\ data['form']['date_from'] < res[0]['date_start']: raise osv.except_osv( _('UserError'), 'Las fechas deben estar entre %s y %s' % (res[0]['date_start'], res[0]['date_stop'])) else: return 'report' else: raise osv.except_osv(_('UserError'), 'No existe periodo fiscal') def period_span(self, cr, uid, ids, fy_id, context=None): if context is None: context = {} ap_obj = self.pool.get('account.period') fy_id = fy_id and type(fy_id) in (list, tuple) and fy_id[0] or fy_id if not ids: # ~ No hay periodos return ap_obj.search(cr, uid, [('fiscalyear_id', '=', fy_id), ('special', '=', False)], order='date_start asc') ap_brws = ap_obj.browse(cr, uid, ids, context=context) date_start = min([period.date_start for period in ap_brws]) date_stop = max([period.date_stop for period in ap_brws]) return ap_obj.search(cr, uid, [('fiscalyear_id', '=', fy_id), ('special', '=', False), ('date_start', '>=', date_start), ('date_stop', '<=', date_stop)], order='date_start asc') def print_report(self, cr, uid, ids, data, context=None): if context is None: context = {} data = {} data['ids'] = context.get('active_ids', []) data['model'] = context.get('active_model', 'ir.ui.menu') data['form'] = self.read(cr, uid, ids[0]) if data['form']['filter'] == 'byperiod': del data['form']['date_from'] del data['form']['date_to'] data['form']['periods'] = self.period_span( cr, uid, data['form']['periods'], data['form']['fiscalyear']) elif data['form']['filter'] == 'bydate': self._check_date(cr, uid, data) del data['form']['periods'] elif data['form']['filter'] == 'none': del data['form']['date_from'] del data['form']['date_to'] del data['form']['periods'] else: self._check_date(cr, uid, data) lis2 = str(data['form']['periods']).replace("[", "(").replace("]", ")") sqlmm = """select min(p.date_start) as inicio, max(p.date_stop) as fin from account_period p where p.id in %s""" % lis2 cr.execute(sqlmm) minmax = cr.dictfetchall() if minmax: if (data['form']['date_to'] < minmax[0]['inicio']) \ or (data['form']['date_from'] > minmax[0]['fin']): raise osv.except_osv( _('Error !'), _('La interseccion entre el periodo y fecha es vacio')) if data['form']['columns'] == 'one': name = 'afr.1cols' if data['form']['columns'] == 'two': name = 'afr.2cols' if data['form']['columns'] == 'four': if data['form']['analytic_ledger'] \ and data['form']['inf_type'] == 'BS': name = 'afr.analytic.ledger' elif data['form']['journal_ledger'] \ and data['form']['inf_type'] == 'BS': name = 'afr.journal.ledger' elif data['form']['partner_balance'] \ and data['form']['inf_type'] == 'BS': name = 'afr.partner.balance' else: name = 'afr.4cols' if data['form']['columns'] == 'five': name = 'afr.5cols' if data['form']['columns'] == 'qtr': name = 'afr.qtrcols' if data['form']['columns'] == 'thirteen': name = 'afr.13cols' return { 'type': 'ir.actions.report.xml', 'report_name': name, 'datas': data }
class pos_order_report_jasper(osv.osv): _name = 'pos.order.report.jasper' _description = 'Reporte Detallado de Ventas' _columns = { 'sale_order_ids': fields.one2many('pos.order.report.jasper.line', 'report_id', 'Pedidos de Venta Relacionados'), 'sale_journal_ids': fields.one2many('pos.order.report.journal.line', 'report_id', 'Metodos de Pago'), 'sale_tax_ids': fields.one2many('pos.order.report.tax.line', 'report_id', 'Impuestos'), 'user_ids': fields.many2many('res.users', 'pos_details_report_user_rel2', 'user_id', 'report_id', 'Usuarios'), 'date_start': fields.date('Date Start', required=True), 'date_end': fields.date('Date End', required=True), 'company_id': fields.many2one('res.company', 'Compañia'), 'name': fields.char('Referencia', size=256), 'date': fields.datetime('Fecha Consulta'), 'total_invoiced': fields.float('Total Facturado', digits=(14, 2)), 'total_discount': fields.float('Descuento Total', digits=(14, 2)), 'total_of_the_day': fields.float('Total del dia', digits=(14, 2)), 'total_paid': fields.float('Total Pagado', digits=(14, 2)), 'total_qty': fields.float('Cantidad de Producto', digits=(14, 2)), 'total_sale': fields.float('Total de Ventas', digits=(14, 2)), } def _get_company(self, cr, uid, context=None): user_br = self.pool.get('res.users').browse(cr, uid, uid, context) company_id = user_br.company_id.id return company_id def _get_date(self, cr, uid, context=None): date = datetime.now().strftime('%Y-%m-%d') date_now = datetime.now().strftime('%Y-%m-%d %H:%M:%S') return date_now # start = datetime.strptime(date_now, "%Y-%m-%d %H:%M:%S") # user = self.pool.get('res.users').browse(cr, uid, uid) # tz = pytz.timezone(user.tz) if user.tz else pytz.utc # start = pytz.utc.localize(start).astimezone(tz) # convert start in user's timezone # tz_date = start.strftime("%Y-%m-%d %H:%M:%S") # return tz_date _defaults = { 'company_id': _get_company, 'date': _get_date, } _order = 'id desc'
class compute_alerts(models.TransientModel): _name = 'hr.schedule.alert.compute' _description = 'Check Alerts' _columns = { 'date_start': fields.date( 'Start', required=True, ), 'date_end': fields.date( 'End', required=True, ), 'employee_ids': fields.many2many( 'hr.employee', 'hr_employee_alert_rel', 'generate_id', 'employee_id', 'Employees', ), } def generate_alerts(self, cr, uid, ids, context=None): alert_obj = self.pool.get('hr.schedule.alert') data = self.read(cr, uid, ids, context=context)[0] dStart = datetime.strptime(data['date_start'], '%Y-%m-%d').date() dEnd = datetime.strptime(data['date_end'], '%Y-%m-%d').date() dToday = datetime.strptime( fields.date.context_today(self, cr, uid, context=context), '%Y-%m-%d').date() if dToday < dEnd: dEnd = dToday dNext = dStart for employee_id in data['employee_ids']: while dNext <= dEnd: alert_obj.compute_alerts_by_employee( cr, uid, employee_id, dNext.strftime('%Y-%m-%d'), context=context) dNext += relativedelta(days=+1) return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'hr.schedule.alert', 'domain': [('employee_id', 'in', data['employee_ids']), '&', ('name', '>=', data['date_start'] + ' 00:00:00'), ('name', '<=', data['date_end'] + ' 23:59:59')], 'type': 'ir.actions.act_window', 'target': 'current', 'nodestroy': True, 'context': context, }
class hr_payslip_employees(models.TransientModel): _name = 'wage.adjustment.employees' _description = 'Generate wage adjustments for selected employees' _columns = { 'employee_ids': fields.many2many( 'hr.employee', 'hr_employee_wage_group_rel', 'adjustment_id', 'employee_id', 'Employees', ), } def _calculate_adjustment(self, initial, adj_type, adj_amount): result = 0 if adj_type == 'fixed': result = initial + adj_amount elif adj_type == 'percent': result = initial + (initial * adj_amount / 100) elif adj_type == 'final': result = adj_amount else: # manual result = initial return result def create_adjustments(self, cr, uid, ids, context=None): emp_pool = self.pool.get('hr.employee') adj_pool = self.pool.get('hr.contract.wage.increment') run_pool = self.pool.get('hr.contract.wage.increment.run') if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] if not data['employee_ids']: raise models.except_orm( _("Warning !"), _("You must select at least one employee to generate wage " "adjustments.")) run_id = context.get('active_id', False) if not run_id: raise models.except_orm( _('Internal Error'), _('Unable to determine wage adjustment run ID')) run_data = run_pool.read( cr, uid, run_id, ['effective_date', 'type', 'adjustment_amount'], context=context) for emp in emp_pool.browse(cr, uid, data['employee_ids'], context=context): # skip contracts that don't start before the effective date of the # adjustment if (run_data.get('effective_date') and run_data['effective_date'] <= emp.contract_id.date_start): continue res = { 'effective_date': run_data.get('effective_date', False), 'contract_id': emp.contract_id.id, 'wage': self._calculate_adjustment(emp.contract_id.wage, run_data['type'], run_data['adjustment_amount']), 'run_id': run_id, } adj_pool.create(cr, uid, res, context=context) return { 'type': 'ir.actions.act_window_close', }
class payroll_register_run(models.TransientModel): _name = 'hr.payroll.register.run' _description = 'Pay Slip Creation' _columns = { 'department_ids': fields.many2many('hr.department', 'hr_department_payslip_run_rel', 'register_id', 'register_run_id', 'Departments'), } def create_payslip_runs(self, cr, uid, ids, context=None): dept_pool = self.pool.get('hr.department') ee_pool = self.pool.get('hr.employee') slip_pool = self.pool.get('hr.payslip') run_pool = self.pool.get('hr.payslip.run') reg_pool = self.pool.get('hr.payroll.register') if context is None: context = {} data = self.read(cr, uid, ids, context=context)[0] register_id = context.get('active_id', False) if not register_id: raise models.except_orm( _("Programming Error !"), _("Unable to determine Payroll Register Id.")) if not data['department_ids']: raise models.except_orm( _("Warning !"), _("No departments selected for payslip generation.")) pr = reg_pool.browse(cr, uid, register_id, context=context) # DateTime in db is store as naive UTC. Convert it to explicit UTC and # then convert # that into the our time zone. # user_data = self.pool.get('res.users').read(cr, uid, uid, ['tz'], context=context) local_tz = timezone(user_data['tz']) utc_tz = timezone('UTC') utcDTStart = utc_tz.localize( datetime.strptime(pr.date_start, '%Y-%m-%d %H:%M:%S')) localDTStart = utcDTStart.astimezone(local_tz) date_start = localDTStart.strftime('%Y-%m-%d') utcDTEnd = utc_tz.localize( datetime.strptime(pr.date_end, '%Y-%m-%d %H:%M:%S')) localDTEnd = utcDTEnd.astimezone(local_tz) date_end = localDTEnd.strftime('%Y-%m-%d') for dept in dept_pool.browse(cr, uid, data['department_ids'], context=context): run_res = { 'name': dept.complete_name, 'date_start': pr.date_start, 'date_end': pr.date_end, 'register_id': register_id, } run_id = run_pool.create(cr, uid, run_res, context=context) slip_ids = [] ee_ids = ee_pool.search(cr, uid, [('department_id', '=', dept.id)], order="name", context=context) for ee in ee_pool.browse(cr, uid, ee_ids, context=context): slip_data = slip_pool.onchange_employee_id(cr, uid, [], date_start, date_end, ee.id, contract_id=False, context=context) res = { 'employee_id': ee.id, 'name': slip_data['value'].get('name', False), 'struct_id': slip_data['value'].get('struct_id', False), 'contract_id': slip_data['value'].get('contract_id', False), 'payslip_run_id': run_id, 'input_line_ids': [(0, 0, x) for x in slip_data['value'].get('input_line_ids', False)], 'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get( 'worked_days_line_ids', False)], 'date_from': pr.date_start, 'date_to': pr.date_end, } slip_ids.append(slip_pool.create(cr, uid, res, context=context)) slip_pool.compute_sheet(cr, uid, slip_ids, context=context) return {'type': 'ir.actions.act_window_close'}
class account_financial_report(osv.osv): _name = "afr" _columns = { 'name': fields.char('Name', size=128, required=True), 'company_id': fields.many2one('res.company', 'Company', required=True), 'currency_id': fields.many2one( 'res.currency', 'Currency', help= "Currency at which this report will be expressed. If not selected will be used the one set in the company" ), 'inf_type': fields.selection([('BS', 'Balance Sheet'), ('IS', 'Income Statement')], 'Type', required=True), 'columns': fields.selection([('one', 'End. Balance'), ('two', 'Debit | Credit'), ('four', 'Initial | Debit | Credit | YTD'), ('five', 'Initial | Debit | Credit | Period | YTD'), ('qtr', "4 QTR's | YTD"), ('thirteen', '12 Months | YTD')], 'Columns', required=True), 'display_account': fields.selection([('all', 'All Accounts'), ('bal', 'With Balance'), ('mov', 'With movements'), ('bal_mov', 'With Balance / Movements')], 'Display accounts'), 'display_account_level': fields.integer( 'Up to level', help='Display accounts up to this level (0 to show all)'), 'account_ids': fields.many2many('account.account', 'afr_account_rel', 'afr_id', 'account_id', 'Root accounts', required=True), 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal year', help='Fiscal Year for this report', required=True), 'period_ids': fields.many2many('account.period', 'afr_period_rel', 'afr_id', 'period_id', 'Periods', help='All periods in the fiscal year if empty'), 'analytic_ledger': fields.boolean( 'Analytic Ledger', help= "Allows to Generate an Analytic Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected" ), 'journal_ledger': fields.boolean( 'journal Ledger', help= "Allows to Generate an journal Ledger for accounts with moves. Available when Balance Sheet and 'Initial | Debit | Credit | YTD' are selected" ), 'partner_balance': fields.boolean( 'Partner Balance', help="Allows to " "Generate a Partner Balance for accounts with moves. Available when " "Balance Sheet and 'Initial | Debit | Credit | YTD' are selected"), 'tot_check': fields.boolean( 'Summarize?', help= 'Checking will add a new line at the end of the Report which will Summarize Columns in Report' ), 'lab_str': fields.char('Description', help='Description for the Summary', size=128), 'target_move': fields.selection( [ ('posted', 'All Posted Entries'), ('all', 'All Entries'), ], 'Entries to Include', required=True, help= 'Print All Accounting Entries or just Posted Accounting Entries'), #~ Deprecated fields 'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'), 'date_to': fields.date('End date'), 'date_from': fields.date('Start date'), } _defaults = { 'display_account_level': lambda *a: 0, 'inf_type': lambda *a: 'BS', 'company_id': lambda self, cr, uid, c: self.pool.get('res.company'). _company_default_get(cr, uid, 'account.invoice', context=c), 'fiscalyear_id': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find( cr, uid), 'display_account': lambda *a: 'bal_mov', 'columns': lambda *a: 'five', 'date_from': lambda *a: time.strftime('%Y-%m-%d'), 'date_to': lambda *a: time.strftime('%Y-%m-%d'), 'filter': lambda *a: 'byperiod', 'target_move': 'posted', } def copy(self, cr, uid, id, defaults, context=None): if context is None: context = {} previous_name = self.browse(cr, uid, id, context=context).name new_name = _('Copy of %s') % previous_name lst = self.search(cr, uid, [('name', 'like', new_name)], context=context) if lst: new_name = '%s (%s)' % (new_name, len(lst) + 1) defaults['name'] = new_name return (super(account_financial_report, self).copy(cr, uid, id, defaults, context=context)) @api.onchange('inf_type') def onchange_inf_type(self): if self.inf_type != 'BS': self.analytic_ledger = False @api.onchange('columns', 'fiscalyear_id', 'period_ids') def onchange_columns(self): if self.columns != 'four': self.analytic_ledger = False if self.columns in ('qtr', 'thirteen'): p_obj = self.env["account.period"] period_ids = p_obj.search([('fiscalyear_id', '=', self.fiscalyear_id.id), ('special', '=', False)]) self.period_ids = period_ids else: self.period_ids = [] @api.onchange('company_id', 'analytic_ledger') def onchange_analytic_ledger(self): self = self.with_context(company_id=self.company_id.id) cur_id = self.env['res.company'].browse(self.company_id).currency_id.id self.currency_id = cur_id @api.onchange('company_id') def onchange_company_id(self): self = self.with_context(company_id=self.company_id.id) cur_id = self.env['res.company'].browse(self.company_id).currency_id.id fy_id = self.env['account.fiscalyear'].find() self.fiscalyear_id = fy_id self.currency_id = cur_id self.account_ids = [] self.period_ids = []
class wolftrakglobal_report_606(osv.osv): _name = 'wolftrakglobal.report606' def _toma_default_pagos(self, cr, uid, context=None): return self.pool.get('account.payment').search( cr, uid, []) # retorna una lista (importate) _columns = { 'invoices': fields.many2many('account.invoice', domain=[('type', '=', 'in_invoice'), ('state', '!=', 'draft'), ('company_id', '=', 3)]), 'payments': fields.many2many('account.payment'), 'dt_payments': fields.selection([('default', 'Default'), ('x', 'y'), ('z', 'aa')], string="Fecha Pagos"), 'desde_606': fields.date('Desde:'), 'desde_str': fields.char(compute='_toma_desde'), 'hasta_606': fields.date('Hasta:'), 'hasta_str': fields.char(compute='_toma_hasta'), 'periodo': fields.char(compute='_toma_periodo', string='Periodo', readonly=True), 'cant_reg': fields.integer('Cantidad de registros'), 'total_rtn': fields.float('ITBIS Retenido: '), 'total_cld': fields.float('Total Calculado: '), 'total_tax': fields.float('ITBIS Calculado: ') } _defaults = { 'desde_606': lambda *a: time.strftime('%Y-%m-01'), 'hasta_606': lambda *a: str(datetime.now() + relativedelta.relativedelta( months=+1, day=1, days=-1))[:10], 'payments': _toma_default_pagos } @api.depends('hasta_606') def _toma_periodo(self): month = str(self.hasta_606[5:7]) year = str(self.hasta_606[:4]) self.periodo = year + month @api.depends('desde_606') def _toma_desde(self): year = str(self.desde_606[:4]) month = str(self.desde_606[5:7]) day = str(self.desde_606[8:10]) self.desde_str = year + month + day @api.depends('hasta_606') def _toma_hasta(self): year = str(self.hasta_606[:4]) month = str(self.hasta_606[5:7]) day = str(self.hasta_606[8:10]) self.hasta_str = year + month + day @api.onchange('invoices') def total_calculado(self): self.total_cld = 0.0 self.total_tax = 0.0 self.total_rtn = 0.0 for value in self.invoices: self.total_cld += value.amount_untaxed self.total_tax += value.amount_tax self.total_rtn += float(value.tax_hold) self.cant_reg = len(self.invoices)
class nutrive_gastos(orm.Model): _name = 'nutrive.gastos' _description = 'Nutrive Gastos' _defaults = { 'date_ini': lambda *a: datetime.date.today().strftime('%Y-%m-%d'), 'date_fin': lambda *a: datetime.date.today().strftime('%Y-%m-%d'), } def create(self, cr, uid, vals, context): print vals return super(nutrive_gastos, self).create(cr, uid, vals, context) _columns = { 'company_id': fields.many2one('res.company', 'Company', required=True), 'period_id': fields.many2one('account.period', 'Period', required=True), 'journal_id': fields.many2many('account.journal', string='Diario'), 'period_name': fields.char('Nombre Periodo'), 'uni_prod': fields.float('Unidades producidas'), 'cto_adicional': fields.float('Costo adicional'), 'gasto_sin_imp': fields.float('gasto'), 'date_ini': fields.date('Fecha inicial', required=True), 'date_fin': fields.date('Fecha final', required=True), } def default_get(self, cr, uid, fields, context=None): res = super(nutrive_gastos, self).default_get(cr, uid, fields, context=context) res['company_id'] = 3 res['period_id'] = 14 return res def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): if context is None: context = {} res = super(nutrive_gastos, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) if view_type == 'form': for field in res['fields']: if field == 'journal_id': res['fields'][field]['domain'] = [('code', 'ilike', 'GTO')] doc = etree.XML(res['arch']) res['arch'] = etree.tostring(doc) return res def execute_query(self, cr, uid, ids, context=None): obj_expense = self.pool['nutrive.gastos'].browse(cr, uid, ids[0], context=context) company_id = obj_expense.company_id.id period_id = obj_expense.period_id.id journal_id = obj_expense.journal_id fecha_fin = obj_expense.period_id.date_stop fecha_ini = obj_expense.period_id.date_start print "Las fechas son:", fecha_fin, fecha_ini # fecha_fin = obj_expense.date_fin # fecha_ini = obj_expense.date_ini journal_select = [0] for journal in journal_id: journal_select.append(journal.id) where = "" if len(journal_select) > 1: where = "AND aj.id IN " + str(tuple(journal_select)) else: obj_ids_default = self.pool['account.journal'].search( cr, uid, [('code', 'ilike', 'GTO')]) where = "AND aj.id IN " + str(tuple(obj_ids_default)) strquery_1 = (""" SELECT *, (T.gasto_sin_impuesto/T.UniProd) ctoadicuni from ( SELECT ap.id, ap.name periodo, sum(ai.amount_untaxed) gasto_sin_impuesto, (select sum(mrp.product_qty) suma_productos from mrp_production mrp WHERE --mrp.date_start between ap.date_start and ap.date_stop --AND mrp.date_finished between ap.date_start and ap.date_stop AND state = 'done' )uniprod FROM account_invoice ai INNER JOIN account_journal aj ON (ai.journal_id = aj.id) INNER JOIN account_period ap ON (ai.period_id = ap.id) WHERE ai.period_id = '%s' AND aj.company_id = '%s' %s GROUP BY ap.id, ap.name, ap.date_start, ap.date_stop )as T """ % (period_id, company_id, where)) strquery = '' strquery = strquery_1 #columnas = 3 #encabezado = "%s,%s,%s,%s,%s" % ( _('Diario'), _('Periodo'),_('GastoTotal'),_('Unidades producidas'), _('Costo adicional')) cr.execute(strquery) registros = cr.fetchall() print registros, '+++++++++++++++++' for move in registros: update = { 'period_id': move[0], 'period_name': move[1], 'gasto_sin_imp': move[2], 'uni_prod': move[3], 'cto_adicional': move[4], 'date_ini': fecha_ini, 'date_fin': fecha_fin } obj_query = self.pool.get('nutrive.gastos').create(cr, uid, update, context=context) #obj_gastos = self.pool['nutrive.gastos'].browse(cr, uid, ids[0], context = context) #obj_product = self.pool['production.product'].browse(cr, uid, ids[0], context = context) product_obj = self.pool['production.product'] query_product = (""" SELECT mp.product_id, mp.product_qty, pt.name FROM mrp_production mp INNER JOIN product_product pp ON (mp.product_id = pp.id) INNER JOIN product_template pt ON (pp.product_tmpl_id = pt.id) WHERE mp.date_finished BETWEEN '%s' AND '%s' AND mp.state = 'done' """ % (fecha_ini, fecha_fin)) strquery_3 = "" strquery_3 = query_product cr.execute(strquery_3) reg_prod = cr.fetchall() for move in reg_prod: update = { 'product_id': move[0], 'product_qty': move[1], 'product_name': move[2], 'id_gasto': obj_query } obj_prod = self.pool.get('production.product').create( cr, uid, update, context=context) query_journal = (""" SELECT aj.name, ap.id id_periodo, ap.name nombre_periodo, sum(ai.amount_untaxed) gasto_detallado FROM account_invoice ai INNER JOIN account_period ap ON (ai.period_id = ap.id) INNER JOIN account_journal aj ON (ai.journal_id = aj.id) WHERE ai.company_id = 3 %s AND ai.state IN ('paid', 'open') AND ai.period_id = '%s' group by aj.name, ap.id, ap.name """ % (where, period_id)) strquery_journal = "" strquery_journal = query_journal cr.execute(strquery_journal) reg_journal = cr.fetchall() for move in reg_journal: update_journal = { 'journal_name': move[0], 'id_periodo': move[1], 'period_name': move[2], 'gasto_detallado': move[3], 'id_gasto': obj_query } obj_journal_details = self.pool.get('journal.details').create( cr, uid, update_journal, context=context)
class hr_schedule_generate(models.TransientModel): _name = 'hr.schedule.generate' _description = 'Generate Schedules' _columns = { 'date_start': fields.date( 'Start', required=True, ), 'no_weeks': fields.integer( 'Number of weeks', required=True, ), 'employee_ids': fields.many2many( 'hr.employee', 'hr_employee_schedule_rel', 'generate_id', 'employee_id', 'Employees', ), } _defaults = { 'no_weeks': 2, } def onchange_start_date(self, cr, uid, ids, date_start, context=None): res = { 'value': { 'date_start': False, } } if date_start: dStart = datetime.strptime(date_start, '%Y-%m-%d').date() # The schedule must start on a Monday if dStart.weekday() == 0: res['value']['date_start'] = dStart.strftime('%Y-%m-%d') return res def generate_schedules(self, cr, uid, ids, context=None): sched_obj = self.pool.get('hr.schedule') ee_obj = self.pool.get('hr.employee') data = self.read(cr, uid, ids, context=context)[0] dStart = datetime.strptime(data['date_start'], '%Y-%m-%d').date() dEnd = dStart + relativedelta(weeks=+data['no_weeks'], days=-1) sched_ids = [] if len(data['employee_ids']) > 0: for ee in ee_obj.browse(cr, uid, data['employee_ids'], context=context): if (not ee.contract_id or not ee.contract_id.schedule_template_id): continue sched = { 'name': (ee.name + ': ' + data['date_start'] + ' Wk ' + str(dStart.isocalendar()[1])), 'employee_id': ee.id, 'template_id': ee.contract_id.schedule_template_id.id, 'date_start': dStart.strftime('%Y-%m-%d'), 'date_end': dEnd.strftime('%Y-%m-%d'), } sched_ids.append( sched_obj.create(cr, uid, sched, context=context)) return { 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'hr.schedule', 'domain': [('id', 'in', sched_ids)], 'type': 'ir.actions.act_window', 'target': 'current', 'nodestroy': True, 'context': context, }