Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is there a beginners' guide to writing a patch?

By
Lawrence
on 8/7/13, 5:43 AM 2,141 views

Hello,

I have not yet written a patch, but have been able to modify some bits of code to get the results I need.

I would like to be able to write these into a patch so that it is easy to apply the changes to files easily after an update. Is there a simple guide to explain how to do this? I notice the patch file works on a basis of removing ("-") and adding ("+") lines of code within the existing file. However I am not certain on how to specify the area where the code should be removed or inserted.

Any tips would be much appreciated!

Thanks, Lawrence

Do you mean a custom module ?

Xsias
on 8/7/13, 6:36 AM

Hello, Use following on terminal : First reach to the folder using 'cd' command where you have made changes. (where addons,server,web files are there)

bzr diff >~/Desktop/patch

Here, /Desktop/test is path where we want to store our file. And patch is the name of file to give. Thanks.

Hiral Patel (hip)
on 8/7/13, 6:52 AM

Hi Xsias, hi Hiral. What I mean is a patch file to amend the code in an existing .py file (in my case I want to add a confirmation button - see http://help.openerp.com/question/8623/warn-user-before-cancelling-a-quotation/). This code is easy to add by manually editing the file with a text editor but is time consuming as I must copy and paste the code in each time I update.

Lawrence
on 8/7/13, 9:09 AM

Yes, so you need a custom module.

Xsias
on 8/7/13, 9:23 AM

Eclipse is good for it. Select folder -> right click on it -> Team -> Apply Patch -> Select file(Patch file) -> Finish.

Hiral Patel (hip)
on 8/7/13, 9:31 AM
0
Xsias
On 8/7/13, 9:34 AM

To create a custom module, you need to create a folder MyModuleName on your folder add-on. On this folder you creae folders/files like this :

MyFolderName

-i18n

-security

--ir.model.access.csv

--security.xml

-__init__.py

-*- encoding: utf-8 -*-
import nameOfMyPyFile

-__openerp__.py

# -*- encoding: utf-8 -*-
{
    "name": "MyModule",
    "version": "1.0",
    "author": "You",
    "website": "",
    "sequence": 0,
    "certificate": "",
    "license": "",
    "depends": [
            "web",
                "base",
    ],
    "category": "Generic Modules",
    "complexity": "easy",
    "description": """

    """,
    "test": [
    ],
    "js": [
    ],
    "css": [
    ],
    "qweb": [
    ],
    "demo_xml": [
    ],
    "images": [
    ],
    "init_xml": [
    ],
    "update_xml": [
        "security/ir.model.access.csv",
        "security/security.xml",
    ],
    "auto_install": False,
    "installable": True,
    "application": False,
}

-nameOfMyPyFile.py

He inherit the base .py and contains your code.

How do you modify or change some .js lines without adding the whole .js again to the module?

Luis Leiva
on 9/13/13, 4:51 PM

Good question, i don't know.

For me, you need to edit the core code.

Xsias
on 9/16/13, 12:51 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 8/7/13, 5:43 AM
Seen: 2141 times
Last updated: 3/16/15, 8:10 AM