code refactoring
This commit is contained in:
parent
2abaabc002
commit
c669ddae2f
@ -2,11 +2,17 @@
|
|||||||
<data>
|
<data>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
<act_window id="golem_resource_report_action" name="Resources_reports"
|
<record model="ir.actions.act_window" id="golem_resource_report_action">
|
||||||
res_model="golem.resource.report.wizard" view_mode="form" />
|
<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 -->
|
<!-- Menus -->
|
||||||
|
|
||||||
<menuitem id="resource_report_menu" name="Report" parent="golem_resource.golem_resource_menu"
|
<menuitem id="resource_report_menu" name="Report" parent="golem_resource.golem_resource_menu"
|
||||||
action="golem_resource_report_action" sequence="10" />
|
action="golem_resource_report_action" sequence="10" />
|
||||||
|
|
||||||
|
@ -18,21 +18,27 @@
|
|||||||
|
|
||||||
""" GOLEM Resources management """
|
""" GOLEM Resources management """
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api, _
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
class GolemResourceReportWizard(models.TransientModel):
|
class GolemResourceReportWizard(models.TransientModel):
|
||||||
"""GOLEM Resource wizard : refusal reason for a reservation """
|
"""GOLEM Resource wizard : refusal reason for a reservation """
|
||||||
_name = "golem.resource.report.wizard"
|
_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)
|
resource_ids = fields.Many2many('golem.resource')
|
||||||
selected_resource_ids = fields.Many2many('golem.resource',
|
|
||||||
domaine="[('id', in, resources_ids.ids)]")
|
|
||||||
date_start = fields.Datetime(required=True)
|
date_start = fields.Datetime(required=True)
|
||||||
date_stop = fields.Datetime(required=True)
|
date_stop = fields.Datetime(required=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def print_report(self):
|
def print_report(self):
|
||||||
for record in 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">
|
<form string="Resource Report">
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="resource_ids" readonly="1" invisible="1"/>
|
<field name="resource_ids" >
|
||||||
<field name="selected_resource_ids" >
|
<tree>
|
||||||
<tree>
|
<field name="name"/>
|
||||||
<field name="name"/>
|
</tree>
|
||||||
</tree>
|
</field>
|
||||||
</field>
|
</group>
|
||||||
</group>
|
<group>
|
||||||
<group>
|
<field name="date_start" />
|
||||||
<field name="date_start" />
|
<field name="date_stop" />
|
||||||
<field name="date_stop" />
|
</group>
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="print_report" string="Print Report" type="object"
|
<button name="print_report" string="Print Report" type="object"
|
||||||
class="oe_highlight" />
|
class="oe_highlight" />
|
||||||
<button string="Cancel" class="oe_link" special="cancel" />
|
<button string="Close" class="oe_link" special="cancel" />
|
||||||
</footer>
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user