Hello, I'm developing a module to take the control of a touristic transportation company what do is make an order service of tours for people taking the data from sale.order.lines (the previously sold tours) and with this info I take the vehicle and operator from Fleet module, and with all this data make the service page.
The problem is after I saved the data I took from sale.order.lines, it saves the data at the table I created but the model don't show it at the view.
This is the code:
----PYTHON file:
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import models, fields, api
class ServicesPage(models.Model):
_name = 'services.page'
name = fields.Char('Referencia Hojas Servicios', readonly=True)
fecha_tour = fields.Date('Fecha de Servicio')
page_lines_id = fields.One2many('page.lines', 'service_page_id', string='LÃneas de Servicio',copy = True)
@api.model
def create(self, vals):
vals['name'] = self.env['ir.sequence'].get('services.page')
return super(ServicesPage, self).create(vals)
@api.multi
def write(self, vals):
result = super(ServicesPage, self).write(vals)
return result
class PageLines(models.Model):
_name = 'page.lines'
name = fields.Char('Referencia LÃnea de Hoja', readonly=True)
product_id = fields.Many2one('product.product', string = "Servicios")
camioneta = fields.Many2one('fleet.vehicle', string='Camioneta')
chofer = fields.Many2one('res.partner', string='Operador')
combustible = fields.Float('Combustible')
entradas = fields.Float('Entradas')
estacionamiento = fields.Float('Estacionamiento')
casetas = fields.Float('Casetas')
viaticos = fields.Float('Viáticos')
derecho_piso = fields.Float('Derecho Piso')
guia = fields.Float('GuÃa')
otros = fields.Float('Otros')
service_page_id = fields.Many2one('services.page', 'Service Page Reference',index=True, copy=False)
service_lines_ids = fields.One2many('services.lines', 'page_line_id', string='LÃneas de Servicio', copy = True)
@api.model
def create(self, vals):
vals['name'] = self.env['ir.sequence'].next_by_code('page.lines')
return super(PageLines, self).create(vals)
@api.multi
def write(self, vals):
result = super(PageLines, self).write(values)
return result
class ServicesLines(models.Model):
_name = 'services.lines'
name = fields.Char('Referencia LÃnea de Servicio',readonly=True)
page_line_id = fields.Many2one('page.lines', 'Page Reference',index=True, copy=False)
service_id = fields.Many2one('sale.order.line', string='Servicios Confirmados')
pax = fields.Integer('No. Personas')
pax_asignado = fields.Integer('Cantidad Personas Asignadas')
@api.model
def create(self, vals):
vals['name'] = self.env['ir.sequence'].next_by_code('services.lines')
return super(ServicesLines, self).create(vals)
@api.multi
def write(self, vals):
result = super(ServicesLines, self).write(values)
return result
----- XML FILE:
<openerp>
<data>
<record id="view_service_page_tree" model="ir.ui.view">
<field name="name">services.page.tree</field>
<field name="model">services.page</field>
<field name="arch" type="xml">
<tree string="Hojas de Servicios">
<field name ="name"/>
<field name ="fecha_tour"/>
</tree>
</field>
</record>
<record id = "view_form_service_page" model = "ir.ui.view">
<field name="name">view_form_create_service_page_ui</field>
<field name="model">services.page</field>
<field name="arch" type="xml">
<form string="Hojas de Servicios">
<sheet>
<div class="oe_title">
<h1>
<field name="name" readonly="1"/>
</h1>
</div>
<group>
<field name="fecha_tour"/>
</group>
<notebook>
<page string="Hojas de Servicios">
<field name="page_lines_id" mode="tree">
<form string="LÃneas de Hojas de Servicios">
<group>
<field name="product_id"/>
<field name="chofer"/>
<field name="camioneta"/>
<field name="combustible" widget="monetary"/>
<field name="entradas" widget="monetary"/>
<field name="estacionamiento" widget="monetary"/>
<field name="casetas" widget="monetary"/>
<field name="viaticos" widget="monetary"/>
<field name="derecho_piso" widget="monetary"/>
<field name="guia" widget="monetary"/>
<field name="otros" widget="monetary"/>
</group>
<notebook>
<page string="Lineas de Servicios">
<field name="service_lines_ids" mode="tree">
<form string="LÃneas de Servicios">
<group>
<field name="service_id"/>
<field name="pax"/>
<field name="pax_asignado"/>
</group>
</form>
<tree>
<field name="service_id"/>
<field name="pax"/>
<field name="pax_asignado"/>
</tree>
</field>
</page>
</notebook>
</form>
<tree>
<field name="product_id"/>
<field name="chofer"/>
<field name="camioneta"/>
<field name="combustible" widget="monetary"/>
<field name="entradas" widget="monetary"/>
<field name="estacionamiento" widget="monetary"/>
<field name="casetas" widget="monetary"/>
<field name="viaticos" widget="monetary"/>
<field name="derecho_piso" widget="monetary"/>
<field name="guia" widget="monetary"/>
<field name="otros" widget="monetary"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="view_pages_lines_tree" model="ir.ui.view">
<field name="name">page.lines.tree</field>
<field name="model">page.lines</field>
<field name="arch" type="xml">
<tree string="LÃneas de Páginas">
<field name="product_id"/>
<field name="chofer"/>
<field name="camioneta"/>
<field name="combustible" widget="monetary"/>
<field name="entradas" widget="monetary"/>
<field name="estacionamiento" widget="monetary"/>
<field name="casetas" widget="monetary"/>
<field name="viaticos" widget="monetary"/>
<field name="derecho_piso" widget="monetary"/>
<field name="guia" widget="monetary"/>
<field name="otros" widget="monetary"/>
</tree>
</field>
</record>
<record id="action_service_page" model="ir.actions.act_window">
<field name="name">Hojas de Servicios</field>
<field name="res_model">services.page</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_fleet_service_page"
name="Hoja de Servicios"
parent="fleet.menu_fleet_reporting"
action="action_service_page"
sequence="3"
/>
</data>
</openerp>