OSError: File not found: library_app\security\library_security.xml
Im trying to upgrade my module but i'm getting this issue.
This is my manifest
{
'name': 'Library Management',
'description': 'Manage library book catalogue and lending',
'author': 'Nicolas Rondon',
'depends': ['base'],
'application': True,
'data': [
'security/library_security.xml',
'security/ir.model.access.csv',
'views/library_menu.xml',
]
}
The xml
<?xml version="1.0"?>
<odoo>
<record id="module_library_category" model="ir.module.category">
<field name="name">Library</field>
</record>
<!-- Library User Group -->
<record id="library_group_user" model="res.groups">
<field name="name">User</field>
<field name="category_id"
ref="module_library_category"/>
<field name="implied_ids"
eval="[(4, ref('base.group_user'))]"/>
</record>
<!-- Library Manager Group -->
<record id="library_group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id"
ref="module_library_category"/>
<field name="implied_ids"
eval="[(4, ref('library_group_user'))]"/>
<field name="users"
eval="[(4, ref('base.user_root')),
(4, ref('base.user_admin'))]"/>
</record>
</odoo>
Actually I'm following Odoo-12-Development-Essentials-Fourth-Edition to learn Odoo. So my code is very similar to the book.
Check the nameofyour model add to _init_ file in pycharm
for example :
from . import Test(name_of_model)
check then file security :
access_Test,access.Test,model_Test,base.group_user,1,1,1,1
check this in manifest:
manifest:
'data': [
'security/ir.model.access.csv'
]
Related
i'm using odoo 15, and i want to change attributes button on stock.quant tree view editable. for code like this:
<xpath expr="//button[#name='action_apply_inventory']" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('inventory_quantity_set', '=', False), ('is_approved', '=', False)]}</attribute>
<attribute name="groups">base.group_system,pitik_base_farm.group_finance_head</attribute>
<attribute name="string">Submit</attribute>
</xpath>
But this code doesn't work, not effect on view.
enter image description here
enter image description here
You are using is_approved field in domain of the invisible attrs but this field does not exist in the view. You need to add it to the view to be able to use it in the domain.
<record id="view_stock_quant_tree_inventory_editable_inherit_custom" model="ir.ui.view">
<field name="name">stock.quant.inventory.tree.editable.inherit.custom</field>
<field name="model">stock.quant</field>
<field name="inherit_id" ref="stock.view_stock_quant_tree_inventory_editable"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='inventory_quantity_set']" position="after">
<field name="is_approved" invisible="1"/>
</xpath>
<xpath expr="//button[#name='action_apply_inventory']" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('inventory_quantity_set', '=', False), ('is_approved', '=',
False)]}
</attribute>
<attribute name="groups">base.group_system,pitik_base_farm.group_finance_head</attribute>
<attribute name="string">Submit</attribute>
</xpath>
</field>
</record>
So I want to change the string of "Purchase Order" inside Purchase Status(Inside Purchase Request) to something like "PO Created" when the purchase_state is in [purchase] but I don't know how I can do it. I want to create fresh module as well.
Here' s what I tried so far. I've created an XML and inherit the view.
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="purchase_request_form_inherit" model="ir.ui.view">
<field name="name">purchase.request.inherit</field>
<field name="model">purchase.request</field>
<field name="inherit_id" ref="purchase_request.view_purchase_request_form"/>
<field name="arch" type="xml">
<field name="purchase_state" position="attributes">
<attribute name="attrs" string="PO Created" attrs="{'readonly': [('po_line.state','=', 'purchase')]}"/>
</field>
</field>
</record>
</odoo>
I prefer use xpath:
<record id="purchase_request_form_inherit" model="ir.ui.view">
<field name="name">purchase.request.inherit</field>
<field name="model">purchase.request</field>
<field name="inherit_id" ref="purchase_request.view_purchase_request_form"/>
<field name="arch" type="xml">
<field expr="field[#name='purchase_state']" position="attributes">
<!-- To change the String -->
<attribute name="string">PO Created</attribute>
<!-- To change the attrs -->
<attribute name="attrs">{'readonly': [('po_line.state','=', 'purchase')]}</attribute>
</field>
</field>
</record>
I hope this answer could be helpful for you.
I am odor newer.
I want to use the sale.order field and value to create a custom report by select some specific
field from sale.order.
I have created a custom model to inherit sale.order model.
And create a view to inherit view of sale.order.
Here is my code:
class SaleOrder(models.Model):
_inherit = 'sale.order'
<field name="name">Custom Sale Report</field>
<field name="res_model">sale.order</field>
<field name="view_mode">tree,form</field>
<field name="name">sale.order.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//field[#name='name']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath> </field> </record>
But I don't know why the invisible attribute is not working.
Please Help. Thanks.
Try this.
<field name="name">sale.order.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_tree" />
<field name="arch" type="xml">
<xpath expr="//field[#name='name']" position="replace">
<field name="name" optional="hide"/>
</xpath>
</field>
</record>
I have the folling XML (as string)
xml = '''
<?xml version="1.0" encoding="utf-8"?>
<Response total="00:00:00.2130175">
<Result>
<Channel name="test">
<TotalCount ignoringpaging="2">2</TotalCount>
<Products>
<Product id="8050" ecommerceproduct="Productname">
<Fields>
<Field name="pid">8050</Field>
<Field name="ProductName">Productname</Field>
<Field name="ProductCategorie" culture="nl-NL">Category</Field>
<Field name="Titel" culture="nl-NL">Product Titel</Field>
<Field name="ProductHoogte">74</Field>
<Field name="ProductVerstelbaarheid">Vast</Field>
<Field name="ProductDikte">25</Field>
<Field name="ProductMateriaal">Gemelamineerd spaanplaat</Field>
<Field name="ProductLijn">0</Field>
<Field name="prodId">63258518</Field>
</Fields>
<Variants>
<Variant id="8060" ecommerceproduct="Productname">
<Fields>
<Field name="ProductName">Productname / Black</Field>
<Field name="PID">8060</Field>
<Field name="Zichtbaar">Y</Field>
<Field name="articleCode">123456</Field>
<Field name="priceExcl">469</Field>
<Field name="ProductBreedte">180</Field>
<Field name="ProductDiepte">80</Field>
<Field name="ProductHoogte">74</Field>
<Field name="varId">121655579</Field>
<Field name="visible">Y</Field>
</Fields>
</Variant>
</Variants>
</Product>
<Product id="8051" ecommerceproduct="Productname 2">
<Fields>
<Field name="pid">8051</Field>
<Field name="ProductName">Productname 2</Field>
<Field name="ProductCategorie" culture="nl-NL">Category</Field>
<Field name="Titel" culture="nl-NL">Product Titel 2</Field>
<Field name="ProductHoogte">74</Field>
<Field name="ProductVerstelbaarheid">Vast</Field>
<Field name="ProductDikte">25</Field>
<Field name="ProductMateriaal">Gemelamineerd spaanplaat</Field>
<Field name="ProductLijn">0</Field>
<Field name="prodId">63258520</Field>
</Fields>
<Variants>
<Variant id="8061" ecommerceproduct="Productname 2">
<Fields>
<Field name="ProductName">Productname 2 / White</Field>
<Field name="PID">8061</Field>
<Field name="Zichtbaar">Y</Field>
<Field name="articleCode">234567</Field>
<Field name="priceExcl">499</Field>
<Field name="ProductBreedte">180</Field>
<Field name="ProductDiepte">80</Field>
<Field name="ProductHoogte">74</Field>
<Field name="varId">216555798</Field>
<Field name="visible">N</Field>
</Fields>
</Variant>
</Variants>
</Product>
</Products>
</Channel>
</Result>
</Response>'''
with xml.etree I can iterate over the Products, but how can I get all the values of the fields and variants fields.
root = ET.fromstring(xml)
for p in root.iter('Product'):
print(p.attrib)
the output I get is:
{'id': '8050', 'ecommerceproduct': 'Productname'}
{'id': '8060', 'ecommerceproduct': 'Productname 2'}
So this seems to work, but whatever I try to get the values from the fields, I get no response.
I have this code in odoo 12 that I want to migrate to odoo 13. But I don't know what is the equivalent of src_model in Odoo 13.
<record model="ir.actions.act_window" id="complete_pieces_jointes">
<field name="name">Complete Pieces Jointes</field>
<field name="view_id" ref="view_id_3"/>
<field name="res_model">ir.attachment.moveto.subscription</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="src_model">ir.attachment</field>
<field name="type">ir.actions.act_window</field>
</record>
Can you help me?
You can look at this example from the SMS module. The src_model has been changed to binding_model.
<!-- Add action entry in the Action Menu for Partners -->
<act_window id="res_partner_act_window_sms_composer_multi"
name="Send SMS Text Message"
binding_model="res.partner"
res_model="sms.composer"
binding_views="list"
view_mode="form"
target="new"
context="{
'default_composition_mode': 'mass',
'default_mass_keep_log': True,
'default_res_ids': active_ids
}"
/>
<act_window id="res_partner_act_window_sms_composer_single"
name="Send SMS Text Message"
binding_model="res.partner"
res_model="sms.composer"
binding_views="form"
view_mode="form"
target="new"
context="{
'default_composition_mode': 'comment',
'default_res_id': active_id,
}"
/>