Show successfully message after close wizard in odoo v9 - odoo

What is best solution for display successfully message after close wizard in odoo 9?
Any small popup in right corner?

It's not a proper answer to your question but i have faced the same problem, the problem was that i have to display "successfully submitted" message when user click on submit button on a wizard. and i have done this as my solution
i have done this
i have created one class for the wizard
from odoo import api, fields, models, _
class CustomPopMessage(models.TransientModel):
_name = "custom.pop.message"
name = fields.Char('Message')
create view for custom wizard
<odoo>
<data>
<record id="custom_pop_message_wizard_view_form" model="ir.ui.view">
<field name="name">custom.pop.message.form</field>
<field name="model">custom.pop.message</field>
<field name="arch" type="xml">
<form string="Custom POP Message">
<field name="name" readonly="1"/>
<footer>
<button string="Close" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>
</data></odoo>
button method of another wizard by pressing that button you want to display certain Pop-Up massage
def my_custom_button_function_for_another_wizard():
return {
'name': 'Message',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'custom.pop.message',
'target':'new',
'context':{'default_name':"Successfully Submitted."}
}

Related

How close a popup model with after saving in odoo 13

I have a problem when i want to close a popup model, only save the data but i want return to invoice.
I open this module from invoice but i want that only close after save not create a new invoice.
something help me please
my code xml
<record id="create_autorizacion_form" model="ir.ui.view">
<field name="name">autorizacion.autorizacion.wizard</field>
<field name="model">autorizacion.autorizacion</field>
<field name="arch" type="xml">
<form string="AutorizaciĆ³n">
<group >
<field name="invoice_amount"/>
<field name="new_balance"/>
<field name="my_credit_limit"/>
</group>
<xpath expr="//sheet" position="after">
<footer>
<button string="Confirm" name="create_autorization" class="btn-primary" special="save"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</xpath>
</form>
</field>
my code .py
class autorizacion(models.Model):
_name="autorizacion.autorizacion"
invoice_amount = fields.Float('Invoice Amount')
new_balance = fields.Float('Total Balance')
my_credit_limit = fields.Float('Partner Credit Limit')
#api.model
def create_autorization(self,vals):
print("funciona")
view = {
'context': self.env.context,
'view_type': 'list',
'view_mode': 'form',
'res_model': 'account.move',
'res_id': self.id,
'view_id': False,
'type': 'ir.actions.act_window',
'nodestroy': False,
'domain': '[]',
'target': 'self',
}
return view
you are trying to create a wizard so for module declaration you need juste to change
this :
class class autorizacion(models.Model):
to this :
class autorizacion(models.TransientModel) :
hope this will help you

How to show a form view by clicking on a record in a many2many field without lifting a modal panel

I have a form with a Many2many field and I'm showing it as a tree view:
By clicking on a record in the Many2many field mentioned above, the form of the corresponding model is lifted in a modal panel, as expected:
I can't find a way to click on a record of the Many2many field, instead of lifting a wizard, I will have the form view corresponding to the model of that Many2many field, without lifting a popup. In other words, this way:
Any suggestions?
You can write an action method on the model and extend the tree view showing this as button. This method should return an action which opens the record in a form view. That's the only "easy" way to do that, with the current Odoo framework.
A little example:
class MyModel(models.Model):
_name = 'my.model'
name = fields.Char()
class MyOtherModel(models.Model)
_name = 'my.other.model'
name = fields.Char
my_model_ids = fields.Many2many(
comodel_name='my.model')
#api.multi
def action_show_record(self):
# only use on singletons
self.ensure_one()
return {
'name': self.name,
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'my.model',
'context': self.env.context,
# don't open a popup
'target': 'current'
}
and the view of my.other.model
<record id="my_other_model_view_form" model="ir.ui.view">
<field name="name">my.other.model.view.form</field>
<field name="model">my.other.model</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
<field name="my_model_ids">
<tree>
<field name="name" />
<button name="action_show_record" type="object"
string="Open" icon="an-font-awesome-icon" />
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>

returning view with all records

So i made a menu that is calling a method that makes some logic and creates records in product.assortment.remove and after all record are created it returns a view. But my problem is that I get the view with 0 records.
My goal is that my method should return a view with all records created and a user can remove some records( with trash icon like in average tree view) how can i acheave that?
P.S.
actually i changed view to tree and <field name="model">assortment.product.removal.wiz</field> to product.assortment.remove and it returned me tree view with all records, but that view is without trash can icon so user can't delete records
class AssortmentProductRemoval(models.TransientModel):
_name = 'assortment.product.removal.wiz'
_description = "Wizard for removing assortment product"
prod_assort_rem_ids = fields.One2many(
'product.assortment.remove', 'product_id',
string='Product Assortmen Remove',)
#api.multi
def _check_assortment_items(self):
<-- some logic here -->
assort_rem_obj = self.env['product.assortment.remove']
vals = ({'qty_sold': qty,
'product_id': product.id,
'profit': profit})
assort_rem_obj.create(vals)
view = self.env.ref('config_hetlita.assortment_product_removal')
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'assortment.product.removal.wiz',
'views': [(view.id, 'form'), (False, 'tree')],
'res_id': self.id,
'target': 'new'
}
class ProductAssortmentRemove(models.Model):
_name = 'product.assortment.remove'
product_id = fields.Many2one(
'product.template', string='Product',
domain=[],
required=False)
turnover = fields.Float(string='Turnover', required=False)
profit = fields.Float(string='Profit', required=False)
qty_sold = fields.Float(string='Quantity sold', required=False)
<record model="ir.ui.view" id="assortment_product_removal">
<field name="name">view.name</field>
<field name="model">assortment.product.removal.wiz</field>
<field name="arch" type="xml">
<form string="Update Set">
<field name="prod_assort_rem_ids" >
<tree editable="bottom">
<field name="product_id"/>
<field name="turnover"/>
<field name="qty_sold"/>
</tree>
</field>
<footer>
<button string="Cancel" icon="gtk-cancel" special="cancel" />
or
<button name="action_save_sol" string="Save" type="object" icon="gtk-ok"/>
</footer>
</form>
</field>
</record>
<record id="action_test2" model="ir.actions.server">
<field name="name">Assortment product removal</field>
<field name="model_id" ref="model_assortment_product_removal_wiz"/>
<field name="state">code</field>
<field name="code">action = self._check_assortment_items(cr, uid, context.get('active_ids'), context=context)</field>
</record>
<menuitem id="your_menu_id12" action="action_test2" parent="base.menu_sale_config" name="Assort remove" sequence="1"/>
Make sure your user have delete access right and you can force the delete icon on the tree like this
<tree delete="1" >
And because you are showing you record in a wizard just show them in form view
# remove views key and use view_id
'view_id': view.id
I think you are missing the delete icon because odoo is showing the record in view mode not edit mode because you used views instead of view_id. Or your user don't have delete access right on the model.

Show from Action Menu the Res_partner Form with partner information corresponding to the current User

In order to show this form view :
<record model="ir.ui.view" id="program_viewform">
<field name="name">My Program</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<form>
<separator string="My Program " />
<field name="projects_ids" nolabel="True"/>
<separator string="submitted Tasks" />
<field name="submission_task_ids" nolabel="True"/>
</form>
</field>
</record>
I created this action :
<record model="ir.actions.act_window" id="myprogram_action">
<field name="name">My Program</field>
<field name="res_model">res.partner</field>
<field name="form_view_id" ref="training_program_management.program_viewform"/>
<field name="domain">[('id','=',user.id.partner_id)]</field>
<field name="view_mode">form</field>
</record>
and this Menu :
<menuitem name="My Program" id="program_menu" sequence="5"
parent="training_program_management.menu" action="training_program_management.myprogram_action"/>
What I need is to show the record of res_partner corresponding to the current User, knowing that res.users contains a Many2one Field "Partner_id".
What do I need to do?
This is tested for odoo 8 but it can probably be adapted for odoo 10 or at least help you :
Change <record model="ir.actions.act_window" id="myprogram_action"> to <record model="ir.actions.server" id="myprogram_action">
Then add (yes, old API is on purpose, it doesn't work with the new API, for odoo 8 that is)
<field name='model_id' ref='base.model_res_partner'/>
<field name="code">
action = self._action_open_user_res_partner(cr, uid)
</field>
Create a model extending res.partner in your module, add (more old API ... also I didn't find a way to use ref())
#api.model
def _action_open_user_res_partner(self, cr, uid):
return {
'view_type': 'form',
'view_mode': 'form',
# Since this is a constant, you can use a global to hold the value for 'view_id'
'view_id': int(self.pool['ir.ui.view'].search(cr, uid,
[('name', '=', 'My Program')])[0]),
'res_model': 'res.partner',
'res_id': int(self.pool['res.users'].browse(cr, uid, [uid])[0].partner_id),
'type': 'ir.actions.act_window',
'context': {}
}
Adapting this to odoo 10 probably involves using the new API instead of the old one. This means self.pool should be self.env or env, and that you don't need cr and uid anymore. You can use user variable instead of uid in the function returning (well actually it could be used for odoo 8 too, but since uid is needed anyway...).
On the other hand, the documentation for odoo 10 about actions strongly suggests you'd still need to use the old API for this, except for model replacing self.
So you should first try something like this for odoo 10 :
<field name='model_id' ref='base.model_res_partner'/>
<field name="code">
action = model._action_open_user_res_partner(cr, uid)
</field>
The function in the model is still the same, since we still use the old API.
If it doesn't work, you should try with the new API (get rid of cr, uid)
The code bellow, worked perfectly for me, Thank you alot for your help:
<record model="ir.actions.server" id="myprogram_action">
<field name="name">My Program</field>
<field name='model_id' ref='base.model_res_partner'/>
<field name="state">code</field>
<field name="code">
action = {
'type': 'ir.actions.act_window',
'name': 'My Program',
'view_mode': 'form',
'view_type': 'form',
'res_model': 'res.partner',
'nodestroy': 'true',
'res_id': int(env['res.users'].browse(env.user.partner_id.id)),
'views': [(False, 'form')],
'view_id': 'ref="training_program_management.program_viewform"',
}
</field>
</record>
Still have a small problem thou, i have two FormViews for res.partner, this line doesn't seem to show the desired View:
'view_id': 'ref="training_program_management.program_viewform"',
It shows me The First FormView That i've inherited.
My training_program_management.program_viewform :
<record model="ir.ui.view" id="program_viewform">
<field name="name">My Program</field>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<form>
<separator string="My Program " />
<field name="projects_ids" nolabel="True"/>
<separator string="submitted Tasks" />
<field name="submission_task_ids" nolabel="True"/>
</form>
</field>
</record>
What can i do to show this View Instead Of the inherited one ?

Odoo 9 yes/no pop-up box python

Odoo v9.
I would like to prompt the user with a yes/no option before certain python code is executed.
If this were in a button I could use the confirm="text?" attribute, however I do not want to trigger any database updates irrespective of the users answer to this particular prompt.
e.g. onchange event triggers yes/no box, which can then manipulate page, however the user still has to press "save" to keep any changes.
Is there any way of doing this using base odoo?
onchange events can't return a dialog because they were simply not built to do that https://www.odoo.com/forum/how-to/developers-13/what-should-onchange-methods-do-and-return-57760
You can use a wizard (it's not really a wizard it's just a form) and show it as a popup. our wizard model will be a Transient model, which would be discarded by odoo after a specified amount of time.
from openerp import fields, models, api
class test_model(models.Model):
_name = 'test.model'
name = fields.Char(string='Value')
#api.multi
def call_up_wizard(self):
return {
'name': 'Are you sure?',
'type': 'ir.actions.act_window',
'res_model': 'wizard',
'view_mode': 'form',
'view_type': 'form',
'target': 'new',
}
class wizard(models.TransientModel):
_name = 'wizard'
yes_no = fields.Char(default='Do you want to proceed?')
#api.multi
def yes(self):
pass
# sure continue!
#api.multi
def no(self):
pass # don't do anything stupid
This is how your view would look like
<record id="cashadvance_list" model="ir.ui.view">
<field name="name">Test Dialog</field>
<field name="model">test.model</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Test Dialog" version="8.0">
<group>
<button class="oe_highlight" name="call_up_wizard" string="confirm" type="object" />
</group>
</form>
</field>
</record>
<record model="ir.ui.view" id="wizard_form">
<field name="name">wizard.form</field>
<field name="model">wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Confirm dialog">
<field name="yes_no" readonly="1" />
<footer>
<button class="oe_highlight" name="yes" string="Yes" />
<button class="oe_highlight" name="no" string="No" />
</footer>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_test">
<field name="name">Cash advance list</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">test.model</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
It's empty, create something
</p>
</field>
</record>
In our test_model view we have a button that's shows the wizard as a popup, and then in the wizard buttons are handled by the yes and no methods respectively, this gives you better control over the buttons as you know have separate methods controlling the two buttons you have on the form.
I just put this answer, for anyone who happens to stumble on this thread and wants to know how to create a popup from a button.