code refactoring
This commit is contained in:
parent
2abaabc002
commit
c669ddae2f
@ -2,11 +2,17 @@
|
||||
<data>
|
||||
|
||||
<!-- Actions -->
|
||||
<act_window id="golem_resource_report_action" name="Resources_reports"
|
||||
res_model="golem.resource.report.wizard" view_mode="form" />
|
||||
<record model="ir.actions.act_window" id="golem_resource_report_action">
|
||||
<field name="name">Resources Reports</field>
|
||||
<field name="res_model">golem.resource.report.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="golem_resource_report_wizard_view_form" />
|
||||
<field name="context">{}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- Menus -->
|
||||
|
||||
<menuitem id="resource_report_menu" name="Report" parent="golem_resource.golem_resource_menu"
|
||||
action="golem_resource_report_action" sequence="10" />
|
||||
|
||||
|
@ -18,21 +18,27 @@
|
||||
|
||||
""" GOLEM Resources management """
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class GolemResourceReportWizard(models.TransientModel):
|
||||
"""GOLEM Resource wizard : refusal reason for a reservation """
|
||||
_name = "golem.resource.report.wizard"
|
||||
def _get_resources(self):
|
||||
return self.env['golem.resource'].search([]).ids
|
||||
|
||||
resource_ids = fields.Many2many('golem.resource',default=_get_resources)
|
||||
selected_resource_ids = fields.Many2many('golem.resource',
|
||||
domaine="[('id', in, resources_ids.ids)]")
|
||||
resource_ids = fields.Many2many('golem.resource')
|
||||
date_start = fields.Datetime(required=True)
|
||||
date_stop = fields.Datetime(required=True)
|
||||
|
||||
@api.multi
|
||||
def print_report(self):
|
||||
for record in self:
|
||||
pass
|
||||
start_date = fields.Datetime.from_string(record.date_start)
|
||||
stop_date = fields.Datetime.from_string(record.date_stop)
|
||||
if start_date > stop_date:
|
||||
raise ValidationError(_("Stop Date cannot be set before \
|
||||
Start Date."))
|
||||
else:
|
||||
domain = [('date_start', '>', record.date_start),
|
||||
('date_stop', '<', record.date_stop),
|
||||
('resource_id', 'in', record.selected_resource_ids.ids)]
|
||||
data = self.env['golem.resource.reservation'].search(domain)
|
||||
|
@ -27,22 +27,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<form string="Resource Report">
|
||||
<group>
|
||||
<group>
|
||||
<field name="resource_ids" readonly="1" invisible="1"/>
|
||||
<field name="selected_resource_ids" >
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date_start" />
|
||||
<field name="date_stop" />
|
||||
</group>
|
||||
<field name="resource_ids" >
|
||||
<tree>
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date_start" />
|
||||
<field name="date_stop" />
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="print_report" string="Print Report" type="object"
|
||||
class="oe_highlight" />
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
<button string="Close" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
Loading…
Reference in New Issue
Block a user