I am using Odoo Online and trying to install a custom module that I have built. I installed the Base import module to allow for installing custom modules on an Odoo Online instance.
I then created a simple module consisting of the following:
mymodule/
__init__.py
__manifeset__.py
product.py
views/
product_product_tree.xml
Here is the content of the files:
__init__.py
from . import product
__manifest__.py
{
'name': "My Module",
'version': '1.0',
'depends': ['stock', 'sale', 'contacts', 'purchase'],
'description': """
Add custom functionality.
""",
# data files always loaded at installation
'data': [
'views/product_product_tree.xml',
],
}
product.py
from odoo import models, fields, api
class ProductProduct(models.Model):
_inherit = 'product.product'
x_reserved_qty = fields.Float(string='Reserved', readonly=True)
views/product_product_tree.xml
<odoo>
<data>
<record model="ir.ui.view" id="mymodule.product_product_tree">
<field name="name">x_product.product.tree</field>
<field name="model">product.product</field>
<field name="priority" eval="16"/>
<field name="inherit_id" ref="product.product_product_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//tree" position="inside">
<field name="x_reserved_qty"/>
</xpath>
</field>
</record>
</data>
</odoo>
I then zip up the file and import it via the Base Import Module. Doing so results in an error and the module does not install. The error is occurring because the x_reserved_qty field does not exist on the model even though I have defined it in product.py. It seems that the python portion of the module is never getting executed.
I can confirm this by commenting out the <field name="x_reserved_qty"/> line, and reimporting the module. This time it imports successfully, but when I browse to Settings > Technical > Database Structure > Fields, I do not see my new field listed anywhere.
Does anybody know if python files are supported for custom modules imported via this Base Import Module method? The module description says:
This module allows authorized users to import a custom data module
(.xml files and static assests) for customization purpose.
It specifically mentions .xml and static assets, but not python files. So, I'm just wondering if I'm doing something wrong in my python files that is causing this not to work, or if it's actually designed not to support python files in modules.
It does not support Python files (probably for security purpuses). For the odoo server to compile your python files it has to be restarted. Something you can not do when you use runbot or Odoo hosts your instance.
Related
I have created a new Theme for Odoo 12 (in EN and AR), the theme works fine on my Environment. But when the theme is copied to live environment, the EN site loads fine, but the AR site goes Grey completely. Can any suggest how to approach this problem. There is no evident error in console.
According to your question, it is possible CSS, qweb and js can't loads.
please add your CSS Js and qweb properly.
I add an example for css or js load
<odoo>
<template id="assets_backend" name="Demo project" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/module_name/static/src/css/custom.css"/>
<script type="text/javascript" src="/module_name/static/src/js/module_name.js"/>
</xpath>
</template>
</odoo>
I developed a new module and I want to add it to my odoo on the server but when I access to my files I don't find addons file in order to put the module. I tried a lot of paths but I didn't find it even my opt file is empty any suggestions or ideas please ? odoo is installed on ubuntu 14.0
I used to find my addons on opt/odoo/odoo
This code I added it just to be able to publish my question because I could not publish it without code
<record id="view_order_product_graph" model="ir.ui.view">
<field name="name">sale.report.graph</field>
<field name="model">sale.report</field>
<field name="arch" type="xml">
<graph string="Sales Analysis" type="pivot" stacked="True">
<field name="section_id" type="row"/>
<field name="date" interval="month" type="col"/>
<field name="price_total" type="measure"/>
</graph>
</field>
</record>
You can put your modules on the system where ever you want. What you have to know is, where to find the server config file. If you've installed Odoo by package installer, it should be in /etc/odoo/*.conf.
In this file you can add paths to the line addons_path=.... Save the config and restart the Odoo instance. Reload the Modules in Odoo and you will find the custom modules.
You can use Python interpreter:
>>> import openerp
>>> openerp.addons.__path__
['/usr/lib/python2.7/dist-packages/openerp/addons']
>>>
Odoo Warning
Odoo Warning - Warning
You are trying to install incompatible themes:
- Add to css (To be installed)
- Default Theme (Installed)
Please uninstall your current theme before installing another one.
Warning: switching themes may significantly alter the look of your current website pages!
this code i am trying
<template id="styles_compiled" inherit_id="website.assets_frontend">
<xpath expr="link[last()]" position="after">
<link rel="stylesheet" href="/add_css_to_website/static/src/css/custom.css" />
</xpath>
</template>
</data>
I got Solution;
1. Please edit a file 'openerp.py' (main directory) and change the line:.
'category' : 'Theme/Backend', with 'category' : 'Website',
2. Next, run 'Update Apps List' from developer mode.
3. Now you can install the theme.
thanks this is working for me... thanks
How do I set a favicon for the web/e-commerce frontend of Odoo 8?
Ideally without changing Odoo core files, i.e. I do not simply want to overwrite addons/web/static/src/img/favicon.ico.
(This is Odoo 8, August 2014. It's likely that it will be easier to change the favicon in future versions.)
You have to override the web module with your own module. You can add a line like
'data': [ 'views/website_templates.xml' ]
in your __openerp__.py.
Put your favicon at static/src/img/favicon.ico and add a template to views/website_templates:
<template id="MYSITE_layout" inherit_id="website.layout" name="MYSITE layout" priority="17">
<xpath expr="//head//link" position="after">
<link rel="shortcut icon" href="/MYSITE_web/static/src/img/favicon.ico" type="image/x-icon"/>
</xpath>
</template>
Favicon is set in <head> html section, that is stored in template, and link there is hardcoded to point to /web/static/src/img/favicon.ico (see here), so if you want to change it you have to change either icon file itself or change proper template to point to icon file you want.
I've create my first plugin for prestashop. I want to add autoupdate functionality for autoupdate as do for example eBay module.
I did not found anything about that on documentation.
I've been struggeling to figure out the correct process for this for a while.
I thought the "upgrade it" button was only available for developers, who release their modules through the prestashop addons website (which is true) but if you chose not to publish there, here's how you update your own modules:
In the main file of your model, within the contructor method, you must have this line of code:
$this->version = '1.0.0';
make a subdirectory in your module folder called upgrade
create a new file in this directory called install-1.0.1.php
put this code in the file:
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_1_0_1($object, $install = false)
{
//your code here, for example changes to the DB...
return true; //if there were no errors
}
?>
In your main file, change it to $this->version = '1.0.1';
Create a zip file of your module folder
Navigate to the Modules page on your stores back end, and say "upload new module"
Upload the zip file
Now you should see 2 messages:
The module was successfully downloaded.
and
The following module(s) were upgraded successfully:
MyModule :
Current version: 1.0.1
1 file upgrade applied
Prestashop Documentation.
You can also add an update file to your module: create an /upgrade folder in your module's folder, and put your update files in it, using the install-1.8.0.php name norm.
<?php
// Sample file for module update
if (!defined('_PS_VERSION_'))
exit;
// object module ($this) available
function upgrade_module_1_8_0($object)
{
// Your code to upgrade from version 1.8.0 of the module
}
?>