Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to enforce a pop up window?

By
Gavin Yap
on 8/14/15, 3:28 AM 909 views

Hi All,

I've created a pop up form and wishes to enforce user to fill in the details without them to close it until it is completed.

An example use case is like a EULA agreement, they have to agree before continuing into the application.

Is there a way to do that?



0
Gavin Yap
On 4/17/16, 8:25 AM

My solution to my problem is to create a menu "eula" with sequence 0, that would trigger a server action.  Whenever a user logins, it will go to the first item of the menu item.  Thus by doing this, it will alway trigger the eula form I intend to display

<menuitem id="main_eula_menu"
name="EULA"
sequence="0"
action="ir_actions_server_eula_trigger"
/>

the menu would then trigger the server action below upon login.

<record id="ir_actions_server_eula_trigger" model="ir.actions.server">
<field name="sequence" eval="5"/>
<field name="state">code</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_eula_eula"/>
<field name="code">action = self.trigger(cr, uid, None, context)</field>
<field name="condition">True</field>
<field name="name">EULA Agreement</field>
</record>

the form below is used to allow user's to agree or disagree the eula.

<record id="view_form_eula" model="ir.ui.view">
<field name="name">view_form_eula</field>
<field name="model">eula.eula</field>
<field name="arch" type="xml">
<form>
<div>
<field name="content"/>
</div>
<footer>
<a href="/eula/agree" class="oe_button">I agree</a>
<a href="/web/session/logout?redirect=/web" class="oe_button oe_highlight">I disagree</a>
</footer>
</form>
</field>
</record>


the Eula model  which has a trigger method to be called by the server action

class Eula(models.Model):
_name = 'eula.eula'
name = fields.Char()
content = fields.Html(readonly=True)
agree = fields.Boolean(string="Agree", help="By checking this, you agree to the EULA.", default=False)
@api.multi
def trigger(self):
_logger.info("Enter Eula Trigger")
return {
'name': 'EULA Agreement',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'eula.eula',
'res_id': 1,
'type': 'ir.actions.act_window',
'target': 'new'
}

Finally a special route and controller to remove the eula menu if accepted.

class Eula(http.Controller):
@http.route('/eula/agree/', auth='user')
def index(self, **kw):
_logger.info(self);
model_datas = http.request.env['ir.model.data'].search([('module', '=', 'eula'), ('model', '=', 'ir.ui.menu')])
for model_data in model_datas:
model_name = model_data.model
model_id = model_data.res_id
model = http.request.env[model_name].search([('id', '=', model_id)])
model.sudo().unlink()
model_data.sudo().unlink()
eula = http.request.env['eula.eula'].search([('id', '=', 1)])
eula.agree = True
return werkzeug.utils.redirect("/")




0

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 8/14/15, 11:18 PM

Try to get this button using xpath expression from the fields_view_get of the wizard class.

Then via a loop set its invisible property to true 

check the code posted in the following two links, it would help expressing my idea

https://www.odoo.com/nl_NL/forum/help-1/question/i-unable-to-change-the-readonly-proprety-of-a-button-from-within-fields-view-get-method-89309 

https://www.odoo.com/nl_NL/forum/help-1/question/i-unable-to-change-the-properties-of-some-fields-from-within-fields-view-get-method-89215 

I investigate, it seems that the fields_view_get does not attribute to disable closing of the pop up form

Gavin Yap
on 8/18/15, 7:26 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/14/15, 3:28 AM
Seen: 909 times
Last updated: 4/17/16, 8:26 AM