Access other address country code in Odoo - odoo

I need to access the country code (country_id) from another address on the contact form as marked in the screenshot. There is a possibility to add more than one 'other' address I guess this is gonna be some kind of list, I need to list all those states.
This is the code I tried to get the country_id on res_partner
<field name="child_ids" domain="[('active','=',True)]" context="{'default_country_id':1}" string="CHILD ID"/>
How can I get that information and show it on a field?

Related

Show customer address from S.O. on delivery slip

In Odoo v15 I am trying to display customer address from Sales Order on delivery slip (report - printed document).
Customer and delivery address are not the same on sales order and on report when I print delivery slip by default it is showing me the same information for contact and delivery address. I tested this on runbot in v16 also - it is strange.
To solve this I inherited 'stock.report_delivery_document' and tried to replace div with name 'partner_header' inside of which should customer address display with this code:
<xpath expr="//div[#name='partner_header']" position="replace">
<span class="pt-5" t-esc="o.partner_id.name"/><br />
</xpath>
The code is giving me info from delivery address, not from Customer that is on Sales Order.
Please help - sorry if creating module is not the way to do it.
I found solution - in inherited "stock.report_delivery_document" I accessed customer address from related Sales Order using o.sale_id.partner_id
Here is the code - used contact widget to format it:
<div t-field="o.sale_id.partner_id" t-options-widget="'contact'"/>

Odoo 16 Can't access another company

everyone! First of all, thanks in advance.
I've searched everywhere for a solution for my problem. Even when copying from the source code, it doesn't solve it.
I'm doing the Advanced B: ACL and Record Rules tutorial
When completing the sub-chapter on multi-company security, I can't do it.
My user can't get access to my new company
The problems I've encountered so far are:
The new company isn't in company_ids
When changing the Default Company and allowed companies, if:
The company is the new company
The only allowed company is the new company
Then, I get the error: Access Error: Access to unauthorized or invalid companies.
I don't know why my new company is invalid
I'm trying to access another company's records
This is my rule:
<record id="estate_private_companies_properties" model="ir.rule">
<field name="name">Privacy Plan Multi-Company</field>
<field name="model_id" ref="model_estate_property"/>
<field name="global" eval="True"/>
<field name="domain_force">[
('company_id', 'in', company_ids)
]</field>
</record>
EDIT:
Sorry for the confusion. I know the xml is not the problem
The problem is that my company is unauthorized or invalid and it doesn't show up in my company_ids
What the xml does is filter so you can only access the estate properties that are assigned to the currently active company (or companies). So it hasn't any effect on creating a company or making a company accessible.
If this is not the problem, please rephrase your question.
Make sure the user you test with has access to the company.
Login as the admin user
go to settings
Users & companies -> Users
select your user
in the user form you see a new field "Allowed Companies" which is only visible once you added a new company.
Make sure the new company is in this many2many list
login as your user

How to add domain filter in odoo search view?

I want to add a custom search filter like this :
when I apply a filter like this is doesn't work
<filter string="Societe" name="company_id" domain='[("company_id","like","")]'/>
in my case, I want the condition is what the user enters on the search input input
It doesn't work because you shoud apply it on the name field.
domain='[("company_id.name","like","")]'
Actually you just need to add the field company_id as extension to a search view or just add it in your own search view:
<field name="company_id" />
And that's it. Now while typing a search term, the search view should show the user multiple search options.

Why not showing custom module in odoo

I have developed new module but facing problem.
Installing custom module on server, without access rights on menus and views, my module works properly.
But when i install module with access rights , just blank page appear instead of list of installed module.
Actual screen:
Blank screen:
Access right:
Security:
One of the thing that i learned when i was learning security in odoo:
if you are getting a blank page that's mean that you did not give you user the needed groups is base.group_user Witch is employee group. because backend is for employee of the company you need to give the user this group in order to see the backend. here is a picture of my screen when i logged ing using the administrator but i removed manually the base.group_user :
so if you are creating a new groups for your new user you need to give it at least base.roup_user
in code example stock_security model :
<record id="group_stock_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="base.module_category_warehouse_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_user')), (4, ref('stock.group_locations'))]"/>
</record>
Here they are defining a new group Named user that include base.group_user
so my question is are you connecting with administrator or a new user
now i have two question :
are you connecting using Administrator or a new user with new groups?
if you are using administrator is the screen i blank page like the one in the picture or you have the menu apps and setting but you don't have your costum menus?
EDITS :
if the menu is not shown to user then the user don't have acces
rights to the model you need to gave the read acces to the group
ir.model.access.csv
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
// in this example all user can read record of model : model.name because you didn't specify the group
"unic_xml_id_for_every_record","name what ever you want","model_model_name",,1,0,0,0
// in this example only user belong to group some_group_xmlid can read record of model.name
"unic_xml_id_for_every_record","name what ever you want","model_model_name","some_group_xmlid",1,0,0,0
// user belong to group some_group_xmlid can read and create records of model.name
"unic_xml_id_for_every_record","name what ever you want","model_model_name","some_group_xmlid",1,0,1,0
exmple
ir.model.access.csv
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"mode_name_id_1","model_name all","model_model_name",,1,0,0,0
"mode_name_id_2","model_name create_acces","model_model_name","some_group_xmlid",1,0,1,0
Could you just show our what you JS console showing?
if you want your user to see a menu that show view of model.test and let us suppose that your used_id is test_user
and your group xml group_xml_id:
add the group to your user :
<!--
this will add the group to the existing groups if you want
to replace them [(6,0,[ref('group_xml_id'),]]
-->
<record id="test_user" model="res.users">
...
...
<field name="groups" eval="[(4, ref('group_xml_id')]"/>
</record>
add access role to users of group_xml_id:
"user_test_full_acces","USER TEST FULL ACCES","model_model_test","group_xml_id",1,1,1,1
if you want the menu to be seen only by the user belong to group group_xml_id:
<menu ....... groups="module_name.group_xml_id"/>
thouse are the roles that you need to respect in order to see the menu.
this query will show if your user have the wanted groups if you don't find the group
then you are doing something wrong you should check __manifest__ may be you forget to
put the xml file.
select p.name, g.name from res_users u
INNER JOIN res_partner p on u.partner_id = p.id
inner join res_groups_users_rel r on u.id = r.uid
INNER JOIN res_groups g on r.gid = g.id
order by p.name

How to take out 'contact' values from a 'Many2one' field in Odoo?

Any Many2one field which is either linked to hr.employee or res.users shows values Home addresses or contacts in the Many2one drop down tool. Anyone has a suggestion on how to stop this ?
You can use domain filter to avoid unwanted results.
For Eg:- In sale order we only see customers although its related object is res.patner, Its because of domain filter( please see the code )
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
Here domain filter is " domain="[('customer','=',True)]" "
ie. records with only customer field is True is shown
From your comments:- If you want to see system users only then user res.users instead of res.partner. Like:-
'user_id' : fields.many2one('res.users', 'User')
Hope this helps.