Odoo Server Action python code open new modal popup - popup

I created Automated action for my partner table on creations add a server action than I want to the server action open a new form on modal popup but I don't write this python code.
Anybodys help me please...

You can add a button, as Yogesh said, but you'll want to make it type object. This will link to a function in the tree's model class, and this function can return a new view. For example, in the xml:
Then in the class definition for this model:
#api.multi
def button_details(self):
view = {
'name': _('Details'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'my.custom.model',
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
'readonly': True,
'res_id': self.id,
}
return view
Make sure to replace 'my.custom.model' with the actual model you want to edit. Also, you'll need to have already definied the ir.actions.act_window and ir.ui.view records for that model, or Odoo won't know how to bring up the details. That top line there is from the new v8 api, but if you're using v7, remove it and just add the standard args to the button_details function call (cr, uid, ids, context). There are lots of examples of button functions in the code, I'm sure you can find one. The key to the button bringing up a new modal window is the line :
'target': 'new',
This will make the details edit be its own little popup window. Alternativly, you can set target to 'current' to just redirect to that page normally, but I'm going to guess in this instance you'd rather a little popup and then return to the main view.
The "'res_id': self.id," line is very important, and I think it only works with the v8 API. If you're using v7, instead of "self.id", you'll probably want the "ids" arg passed in from the function arguments. I hope that makes sense.

#api.multi
def button_approved(self):
self.ensure_one()
return { 'name': 'My Name',
'type': 'ir.actions.act_window',
'views':[[False,'form']],
'res_model': 'my.custom.model',
'target': 'new',
'context': {'default_my_type':'state','default_model_id':self.id} }
but this code for button. I want to automatic actions for when created my.partner.model Your code doesn't work for server actions python code

As far as I understood you need to create a wizard using only xml files so that you can upload on saas, so here after creating automated action then you need to create a view and action and bind that action with your server action.
View:
<record model="ir.ui.view" id="view_name_wizard">
<field name="name">name.wizard.form</field>
<field name="model">model_name</field>
<field name="priority">16</field>
<field name="arch" type="xml">
your fields # remember to add new model and fields from xml
</field>
</record>
Action:
<record id="action_name_wizard" model="ir.actions.act_window">
<field name="name">Title</field>
<field name="type">ir.actions.act_window</field>
<field name="target">new</field>
<field name="res_model">model_name</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_name_wizard"/>
</record>
Now say if you want to popup this wizard on automated action you need to add this action on server action with this. action_name_wizard .
Tell me if you need anything more.

Related

Odoo 10, Importing res partner with tags with an XML when installing a module

I need to import customers data with tags into res.partner with an XML when installing a custom module.
"Customers" data is stored in res.partner and "Tags" data is stored in res.partner.category, they have a relationship Many2many through res_partner_res_partner_category_rel.
I'm calling two XML files in the __manifest__.py:
The first one populates successfully res.partner.category:
<?xml version="1.0"?>
<odoo>
<record model="res.partner.category" id="res_partner_category_1">
<field name="name">Heavy metal</field>
<field name="active">1</field>
</record>
</odoo>
The second one inserts the partner data:
<?xml version="1.0"?>
<odoo>
<record model="res.partner" id="res_partner_predata_1">
<field name="name">Iron Maiden</field>
</record>
</odoo>
All I need is to insert this res.partner registry with the "Heavy metal" Tag with the installation of a custom module like this:
This is how it would look:
I will deeply appreciate any help.
I found the answer in the Odoo demo data:
When I created the category Heavy metal I assigned the id res_partner_predata_1, then I only have to add the next line (the one after the comment) to the res_partner registry like this:
<?xml version="1.0"?>
<odoo>
<record model="res.partner" id="res_partner_predata_1">
<field name="name">Iron Maiden</field>
<--! This line will add the category-->
<field eval="[(6, 0, [ref('module_name.res_partner_category_1')])]" name="category_id"/>
</record>
</odoo>
I faced the same question with odoo 14. In my case your solution did not work completely. Instead of:
<field eval="[(6, 0, [ref('module_name.res_partner_category_1')])]" name="category_id"/>
I had to set:
<field name="category_id" eval="[(6,0,[ref('res_partner_category_1')])]"/>

Make notes global?

I have a client who wants to use notes and have them global across all users. It would be easiest to just remove the user dependency to display to all users. The other option is to add message_follower_ids upon creation to add a "general" channel as a follower but I'm clueless as to what the values would be.
Any thoughts, ideas, advice is greatly appreciated.
You can achieve using two methods.
You can inactive record rule of note.
<record id="note.note_note_rule_global" model="ir.rule">
<field name="name">Only followers can access a sticky notes</field>
<field name="model_id" ref="note.model_note_note"/>
<field name="active" eval="False"/>
<field name="domain_force">['|', ('user_id', '=', user.id), ('message_partner_ids', '=', user.partner_id.id)]</field>
<field name="global" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
If you inactive above record rule then odoo will visible notes to all users.
Add followers inside note.
If you hide some notes for some users then you must not inactive record rule and just add followers.
This may help you.

Set test parameter in test instance using HP QC REST API

Is there any way to create test instance with parameter using the REST API on QC 11 ?
I have a test in my test plan with some parameters, or just one for the exercise :
I want to create using the rest API :
A test set in my test lab
A test instance in this test set
A test run of my test (the one in the plan) in this test instance
And be able to set the value of my parameters
I have manage to do the first 3 points. But I can not find how to set the parameter value for my instance. If I create the tests manually it is asked during the add of the test in the instance. And I can find the parameters in the Execution Settings in the Test Instance detail :
I have search in the documentation, but didn't find anything about how to set/use theses parameters. I have made GET on every objects, but didn't find them. I also try some urls like :
/test-instances/25378/test-parameters
/test-instances/25378/execution-settings
/test-instances/25378/exec-settings
But they always return 404.
Is there any way to set these parameters values ?
I had same troubles and here is my solution.
You can query your test parameters as:
/tests/{id}/test-parameters
And your test instance parameters, which are effectively actual values for those in your test instance, with:
/test-instances/{id}/step-parameters
For parameter values created via UI it returns like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Entities TotalResults="1">
<Entity Type="step-parameter">
<ChildrenCount>
<Value>0</Value>
</ChildrenCount>
<Fields>
<Field Name="origin-test">
<Value>-1</Value>
</Field>
<Field Name="vc-user-name">
<Value></Value>
</Field>
<Field Name="id">
<Value>21</Value>
</Field>
<Field Name="parent-id">
<Value>46</Value>
</Field>
<Field Name="used-by-owner-type">
<Value>test-instance</Value>
</Field>
<Field Name="actual-value">
<Value><html><body>
<div align="left">
<font face="Arial"><span style="font-size:8pt">AAA</span></font>
</div>
</body></html></Value>
</Field>
<Field Name="key">
<Value></Value>
</Field>
<Field Name="used-by-owner-id">
<Value>34</Value>
</Field>
</Fields>
<RelatedEntities/>
</Entity>
</Entities>
Where used-by-owner-id is id of the test-instance and parent-id is id of test parameter of the test.
Actual value for this case is AAA wrapped up with html tags.
You can create step parameters like this using normal POST to url:
/step-parameters
Note: Don't use same nested url for creation as you use for retrieval. You'll not be able to create parameters with such a combination of parameters you need.
API documentation really sucks, but you can get ideas how to retrieve or create things you need by requesting entity schema with
/customization/entities

Difference between "group" and "component" in QuickFIX/J

I am new to the FIX world. I am writing an application processing FIX messages in Java and for that I am using QuickFIX/J. I have downloaded the DataDictionary from the homepage (http://quickfixengine.org/). I am using the version 4.4.
In the XML-file exist groups and components. But a component can contain groups again.
What's the exact difference between them?
Components aren't really... things. They're like macros in the FIX DataDictionary (DD). Many messages need the same set of fields, so instead of specifying the same fields in every message, the DD defines a component that other messages can include.
A Group, on the other hand, is a very real thing. It's a repeating sequence of fields that will appear 0 or more times in a message.
QuickFIX's (QF) programming interface largely ignores components as a concept. You can't extract a component from a message because a component isn't a concept in QF; you just extract the fields like any other field.
A hypothetical example: The following two message definitions are exactly the same.
With a component
<message name="Automobile" msgtype="X" msgcat="app">
<field name="Wheel" required="Y"/>
<field name="Bumper" required="Y"/>
<component name="Dashboard" required="Y"/>
</message>
<component name="Dashboard">
<field name="Radio" required="Y"/>
<field name="AirConditioner" required="Y"/>
<field name="Heater" required="Y"/>
</component>
Without a component
<message name="Automobile" msgtype="X" msgcat="app">
<field name="Wheel" required="Y"/>
<field name="Bumper" required="Y"/>
<field name="Radio" required="Y"/>
<field name="AirConditioner" required="Y"/>
<field name="Heater" required="Y"/>
</message>
See? A component is pretty much just a macro.
Either way it's defined, you just end up calling msg.GetHeater() (or whatever).
From the FIXWiki for Components:
Component blocks are sets of related data fields grouped together and are referenced by the component block name in messages that they are used in. Sometimes they are referred to as "Groups".
Component blocks are practical to be defined, and then reused in different message types. Sometimes a repeating group is just for one particular message and then it is not defined as a Component block.
View a component block as a reusable definition of fields. Such a component block may or may not contain a repeating group of fields.
For instance take the Parties component block which is used in many different messages types (see "Used In" on that page). Easy to define once and use in many definitions of messages.
Just going to add some information since the accepted answer is missing this information (probably due to the fact that it is about five years old now).
In QuickFIX/J you are actually able to get and set components. So you can for example simply copy the Instrument component from one message to another.
#Test
public void testComponent() throws Exception {
final Instrument instrument = new Instrument();
instrument.set(new Symbol("DELL"));
instrument.set(new CountryOfIssue("USA"));
instrument.set(new SecurityType(SecurityType.COMMON_STOCK));
final quickfix.fix44.NewOrderSingle newOrderSingle = new quickfix.fix44.NewOrderSingle();
newOrderSingle.set(instrument);
final quickfix.fix44.ExecutionReport executionReport = new quickfix.fix44.ExecutionReport();
executionReport.setComponent(newOrderSingle.getInstrument());
System.out.println("NOS: " + newOrderSingle.toString().replace('\001', '|'));
System.out.println("ER: " + executionReport.toString().replace('\001', '|'));
}
Output:
NOS: 8=FIX.4.4|9=28|35=D|55=DELL|167=CS|470=USA|10=233|
ER: 8=FIX.4.4|9=28|35=8|55=DELL|167=CS|470=USA|10=221|
Maybe this is also possible in the other QuickFIX language variants.

OpenERP modeling / views: related object inline

I have installed the built in OpenERP 6.1 module crm.
As a result, I now have res.lead active and visible at "Sales->Opportunities".
I'd like to edit this object / view to show the partner's billing address.
Since I want to do this on the Opporunities form, there is already a partner_id.
Copying another module, I defined my new module like this:
class crm_lead(osv.osv):
_name = _inherit = 'crm.lead'
_columns = {
'billing_address_id': fields.many2one('res.partner.address', 'Partner Billing Address', domain="[('partner_id','=',partner_id),('type','in',['invoice', 'default'])]"),
}
And I changed my update_xml to:
<record model="ir.ui.view" id="crm_case_form_view_oppor">
<field name="name">Opportunity form (inherit)</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<data>
<separator string="Details" position="replace" />
<field name="description" position="replace">
<group colspan="2" col="4">
<separator colspan="4" string="Billing" />
<field widget="one2many_list" mode="form,tree" name="billing_address_id" colspan="4" nolabel="1" />
</group>
<group colspan="2" col="4">
<separator colspan="4" string="Details" />
<field name="description" nolabel="1" colspan="4" />
</group>
</field>
</data>
</field>
</record>
The problem is that the related object shows all the related fields (as I'd guess would be expected). In particular, it shows the partner_id and company fields, which I'd like to hide since they should default to / inherit from this opportunity (or the linked partner).
How can I hide these fields? I can't simply add a bunch of 'related' fields, as there is potentially more than one billing address.
Thanks for the help!
Edit: To be clearer, an opportunity should only have a single chosen billing address, chosen from the partner's invoice / default addresses. It should be displayed inline to allow easy editing.
There are a couple of ways to specify the view for related fields like this. You can use the context like this:
<field
name="order_line"
colspan="4"
nolabel="1"
context="{'form_view_ref': 'module.view_id', 'tree_view_ref': 'model.view_id'}"/>
You can also specify the whole view for the child record as a subview within the parent view like this:
<!-- <=== order_line is a one2many field -->
<field name="order_line" colspan="4" nolabel="1">
<form>
<field name="qty"/>
...
</form>
<tree>
<field name="qty"/>
...
</tree>
</field>
OK, I was a bit confused because you put a one2many widget on a many2one field.
If you want to control how a one2many field is displayed, use the subview or context methods I mentioned in my other answer.
If you want to control how a many2one field is displayed, you might be able to use related fields that pull fields from the record you selected, but I doubt it. Read-only might work, but I don't think it makes sense to edit multiple related fields and be able to change the selected record. You might be able to hack together some function fields with a store function that lets you write back to the related record, but it seems like it would really confuse your users.
On any OE Relation field you can define the Intenal View like :
<field name="" mode="tree,form">
<!--Internal tree view for your Relation field model-->
<tree>
</tree>
<!--Internal Form view for your Relation field model-->
<form>
</form>
</field>
Example Under Addons 1 Click to Example 2 Click to See Example
Hope this will help you,.
Now if yo uwan to shoe specific detail on your m2o file then we have some optional way also where you have to over the def name_get of your relational model, namge get look like :
name_get(cr, user, ids, context=None)
Returns the preferred display value (text representation) for the records with
the given ids. By default this will be the value of the name column, unless the
model implements a custom behavior. Can sometimes be seen as the inverse function
of name_search(), but it is not guaranteed to be.
Rtype : list(tuple)
Return : list of pairs (id,text_repr) for all records with the given ids.
So here in this method you can decide what string you want to show your relational field.
Example
This will fix your problem partially i guess.