Giter Site home page Giter Site logo

odoo_samples's Introduction

Information

This repository contains samples in different modules. Every folder is a module which you can easily install to see how things work or you can browse the code!

Module button_action_demo

This module will learn you how to create buttons at the top of forms and how to make it perform actions. All Python (model data) is under models/button_action_demo.py and you can find the views under views/button_view.xml.

Module default_data_demo

This module will learn you how to automatically insert default data in to a database. It will create a new model (demo.default.data) which is filled with records that are made in the file defaultdata.xml (under data/ folder).

Module default_filter_demo

This module will learn you how to add filters on search views. It'll allow you to filter on a specific field by simply using the filter from the searchview.

Module inherit_report_demo

This module will learn you how to inherit existing QWeb reports and how to modify them. In this example I will modify the default quotation/order report and only show the description with the total price. To make it look a bit better I've added a table header color.

Module logging_demo

This module will learn you how to create log statements in Odoo. You can use these log statements to debug values or to write unusual behaviour to the Odoo logfile.

Module mail_template_demo

This module will learn you how to create e-mail templates in Odoo. It will add a new e-mail template for the model ```res.partner``` and will learn you the basic concepts of e-mail templates and jinja2 rendering.

Module send_mail_template_demo

This module will learn you how to send out e-mail templates from Python code. In this example we'll add a send e-mail button. After clicking on it the e-mail template that we created in the module mail_template_demo will be used to send out an e-mail.

Module many2many_default_data_demo

This module is a new module from scratch that inherits sale.order. It will create a new many2many to the model sale.order.printorder and will automatically fill this many2many with all the data from the model sale.order.printorder. In this sample you can see how to use default=, how to use functions and how to use self.pool.

Module many2many_handle_widget_demo

This module is a new module from scratch that inherits sale.order. In this module you can see how the handle widget (drag and drop) works with many2many and how sequencing works.

Module on_change_function

This module is a new module from scratch which inherits the model product.template. It adds the fields CostPrice and ShippingCost, which you can see in models.py. This is also where the on_change event is programmed. The fields are then added to the products view in the file templates.xml, which inherits the default product view.

Module project_task_agenda_colouring

Note: If you want to use this module you will also need to install the module web_widget_color. This module builds on top of that module. This module will give you the ability to add custom colours to tasks which will then re-color the agenda view. There is a new view created 'Agenda statuses' where you can create a status with a color from the color picker. On the project task you can then choose an agenda status. When you'd go to the agenda view you will see it being re-coloured. This module does almost the same as ```project_task_kanban_colouring``` but this module colours the agenda view, not the Kanban view. Agenda statusses view:

Agenda statuses


Project task view:

Project task view


Tasks calendar view:

Project tasks calendar view

Module project_task_kanban_colouring

Note: If you want to use this module you will also need to install the module web_widget_color. This module builds on top of that module. This module will give you the ability to add custom colours to tasks which will then re-color the agenda view. There is a new view created 'Agenda statuses' where you can create a status with a color from the color picker. On the project task you can then choose an agenda status. When you'd go to the kanban view you will see it being re-coloured. This module does almost the same as ```project_task_agenda_colouring``` but this module colours the Kanban view, not the agenda view. Agenda statusses view:

Agenda statuses


Project task view:

Project task view


Tasks kanban view:

Project task kanban view

Module sale

This module is the default sale module with a few modifications. All the changes can be seen in sale.py and sale_view.xml.
Changes in sale.py: ``` def _get_default_currency(self, cr, uid, context=None): res = self.pool.get('res.company').search(cr, uid, [('currency_id','=','EUR')], context=context) return res and res[0] or False
_columns = {
    #This fills the Many2one with all data from res.currency
    'currency_id_invoices': fields.many2one('res.currency', string="Valuta", required=True),
  
_defaults = {
    #This makes the function go off that sets EUR.
    'currency_id_invoices': _get_default_currency,
Changes in sale_view.xml:
<field name="currency_id_invoices"/>

<h3>Module scheduler_demo</h3>
This module is a new module, from scratch, which creates a new model (scheduler.demo), new views and an automated action (scheduler). This module will learn you how to create an automated action from scratch, how to loop over all records in a model and how to update those values from within a scheduler.

<h3>Module static_resources_demo</h3>
This module is a new module, from scratch which creates a new CSS and JavaScript file.
This module will learn you how to create new static files and how to add them to the main Odoo CSS / JavaScript.

<h3>Module statusbar_demo</h3>
This module is a new module, from scratch, which creates a new model (statusbar.demo) and new views.
This module will learn you how to create a statusbar (selection) and how to handle different states and writing on the current record. You will learn how to add buttons, how to trigger functions and how to change the state of your record.

<h3>Module upload_images</h3>
This module is a new module, from scratch, which creates a new model (upload_images.tutorial), a new report (report_images.xml) and a new menu_item named 'Images' under Sales. In this new menu item you can upload images in multiple sizes and you will see a new report detail here. With this report you will see the image printed in multiple sizes.

<h3>Module user_access_rights_demo</h3>
This module creates a new security selection on the user settings. This allows you to add users to groups under Settings > Users and gives you the ability to show views and fields only to specific user groups.

<h3>Module web_widget_color</h3>
This module adds a colour picker widget to Odoo. The picker itself is inspired on the <a href="http://jscolor.com">jsColor </a> library.
To use this widget you need to create a char field in with a size of atleast 7 characters in the database:

color = fields.Char( string="Color", help="Choose your color" )

Afterwards call it in the view with ```widget="color"```:
... ... ``` Picker sample:


Tree view sample:

Module xpath_expressions

This module is a new module, from scratch which inherits the model product.template and inherits the product view (sale > products). In this sample you can see how to add new pages, groups or fields with xpath expressions. You can see the samples in templates.xml.

odoo_samples's People

Contributors

yenthe666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

odoo_samples's Issues

erppeek access denided

hi @Yenthe666 @warrag @yenykm I am having same issue in version 15.0 while trying to access through python script
in odoo.conf admin_passwd is admin
I have use same
DATABASE = db_name
SERVER = 'http://localhost:8069/'
ADMIN_PASSWORD = 'admin'
client = erppeek.Client(server=SERVER)
client.create_database(ADMIN_PASSWORD,DATABASE)
but getting issue, can someone guide me please ?

Uninstall modules Exception

Hello @Yenthe666

when I uninstall modules from server this Exception comes

<Fault warning -- One or more of the selected modules have already been uninstalled, if you believe this to be an error, you may try again later or contact support.: ''>

and this my code:
modules = client.modules('enterprise', installed=True) if 'web_enterprise' in modules['installed']: for m in modules['installed']: client.uninstall(str(m))

any solutions

odoo 8 : export accounts list to import it into odoo 10 or 11

Dear,

I am looking to migrate from odoo 8 to odoo 10 or 11 community version.

I tried to export my accounts list and products but there are too many fields are linked with other tables.

Do you have any idea if a script is available to do that ?

Best Regards
Youssef

Can you help me

Can you help me with this email script?

I dont get it, this is my base.py file:

from openerp import models, fields, api
from openerp.osv import fields, osv

def send_mail_example(self,cr,uid,ids,odoo_record,context=None):
    ir_mail_server = self.pool.get('ir.mail_server')
    title = "Your e-mail title"
    message = "This is the concent from your e-mail. An example from a field inside the e-mail: " + odoo_record.odoo_dns_url + "\n\nWith kind regards,\nYenthe"
    #Structure mail function: def build_email(self, email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False,
        msg = ir_mail_server.build_email("[email protected]", ["[email protected]"], title, message,["[email protected]"],[],"[email protected]")
        ir_mail_server.send_email(cr, uid, msg)

The form is with this:

              <form name="mailsend" method="post">
                <table border="0" cellspacing="0" cellpadding="2">
                    <tbody>
                        <p>text:</p>
                            <tr>
                            <td><textarea cols="50" rows="5" name="Mitteilung">Ihre Mitteilung</textarea></td>
                            </tr>
                            <tr>
                            <td>
                            <!--<input type="submit" value="Abschicken" />--><button name="send_mail_example" type="object" string="Send E-mail">SEND</button>
                            </td>
                            </tr>
                    </tbody>
                </table>
              </form>

Version

What version of odoo is this? Thanks!

xpath using "string" attribute

"string" attribute sems to be depreciated in odoo9 ...
need to check the code against trunk (future odoo v9)

this: expr="//page[@string='Information']/group" will not work anymore...

all other xpath handlers seems to work fine...

greetz bole ;)

ERPpeek AccessDenied

Hello every one

When I am using this lib I got xmlrpc.client.Fault: <Fault AccessDenied: 'Access denied'>

@Yenthe666 please any help with this

best regards

Attribute not registered

Hi,

I am new to odoo modules development. I tried to add new fields and new method action into button_action_demo but it seems like it always give men attribute error, attribute not registered issues. are you able to let me know on what is my issues or is there anywhere i need to register?

Thanks.
Regards,
Ferry

Odoo performance

Hi Yenthe,

Today, I have found a thing correlated with the performance in Odoo, so I would like to discuss this with you to see whether it could be called an issue or not?

I have checked it on the latest Odoo (version 12), it has still been there.

The thing I have found, I will describe as code to esaier to explain:

  1. I have a model called "testA", a computed field called "computed_field" inside this model.

class TestA(models.Model):
_name = "testA"

computed_field = fields.Char('Computed field', compute='_test_compute')

@api.multi
def _test_compute(self):
    return True
  1. In another model, I have a function to handle some thing, but I will loop on records in the model "testA" and call the computed field.

class TestB(models.Model):
_name = "testB"

# some fields here, but we should not care..


def _test_function(self):
	
	# First, I will get all the data in the model "testA"

	# Getting all data or adding domains to filter, this is not important. The thing we need to have is list of data in testA. In this case, I will have all data, and for example I will have 100 records with ids from 1 to 100

	# testA_records = (1, 2, 3, ....., 100) => This is an sample I have the data in testA_records

	testA_records = self.env['testA'].search([])  

	# After that, I will do a loop on the array testA_records

	for item in testA_records:
		# call the compute field
		computed_value = item.computed_field
  1. At this time, we can see everything is normal. The thing I want to tell is:

If the current item in the loop is 1 (object of testA with id = 1), then when the computed function called, the value of self should be the same. It would be (object of testA with id = 1) too.

But, the thing I do not understand why is although the current item in the loop is 1, but the self in the computed function is one list of items with ids from 1 to 100?

This leads to an issue related to the performance. If the computed function taking to run about 5s for each call, we have 100 items here, it would take time to run is 5s * 100 = 500s. I see passing redundant items to self, it does not make sense, and it makes the time execution slower.

I do not know whether it should be an issue in Odoo or not. Anyone else, Can you explain its reason? and also the solution to bypass it.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.