Thursday, 13 April 2017

How to inherit js file in odoo ?

First, you define a template in your module to add your js assets located in static/src/js:

<template id="assets_backend" name="newmodulename assets" inherit_id="web.assets_backend"> 
           <xpath expr="." position="inside"> 
               <script type="text/javascript" src="/newmodulename/static/src/js/custom.js"></script> 
           </xpath>
</template>
Then, in your module's new js file, you extend the widget from default module like this:

odoo.define('newmodulename.newmodulename', function (require){
"use strict";
// require original module JS
var instance = openerp;

// Extend widget
instance.web.form.One2ManyListView.include({
    ....
    your code to override here    
    ....
});

}

How to call model objects at xml qweb?

<t t-foreach="request.env['your.model'].search([])" t-as="obj">
    <t t-esc="obj.name"/>
</t>

Monday, 3 April 2017

Second approval from RFQ to PO (based on amount) in odoo

Step 1 :  Go to Settings > Purchase > tick the field " Force two levels of approvals " and also you can set the limit amount in " limit to require a second approval ".

so when purchase order exceed this limit of amount. then system will ask for second approval from manager.



Step 2 : you can see in below screen shot that system showing second approved button for approval.




Tuesday, 28 March 2017

How to Define Recurring Entries in odoo ?


Step 1 : Go to Accounting > Periodic Processing > Recurring Entries > Models and Create Model As shown as below.


Step 2 :  Define Recurring Entries and Fill the data as shown in screenshot.


Step 3 : to automatically create entries based on the recurring entries we have set before >> click Generate entries as per the screenshot below.



Step 4 :  you can see the generated entries in “Journal Entries” Tab. as shown in below screenshot.


Thursday, 23 March 2017

what is ondelete optional parameter in odoo

It is Foreign Key constraint on delete records in your object. These parameters define constraint on PostgreSQL level.
Restricting and cascading deletes are the two most common options. RESTRICT prevents deletion of a referenced row. NO ACTION means that if any referencing rows still exist when the constraint is checked, an error is raised; this is the default behavior if you do not specify anything. (The essential difference between these two choices is that NO ACTION allows the check to be deferred until later in the transaction, whereas RESTRICT does not.) CASCADE specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well. There are two other options: SET NULL and SET DEFAULT. These cause the referencing columns to be set to nulls or default values, respectively, when the referenced row is deleted. Note that these do not excuse you from observing any constraints. For example, if an action specifies SET DEFAULT but the default value would not satisfy the foreign key, the operation will fail.

Wednesday, 22 March 2017

How many widget we can use in odoo v8?

Here are the latest widgets and its following classes usable in odoo js to include or extend also use syntax widget="any_widget_name" with odoo views,
    'char' : 'instance.web.form.FieldChar', 
    'id' : 'instance.web.form.FieldID',
    'email' : 'instance.web.form.FieldEmail',
    'url' : 'instance.web.form.FieldUrl',
    'text' : 'instance.web.form.FieldText',
    'html' : 'instance.web.form.FieldTextHtml',
    'char_domain': 'instance.web.form.FieldCharDomain',
    'date' : 'instance.web.form.FieldDate',
    'datetime' : 'instance.web.form.FieldDatetime', 
    'selection' : 'instance.web.form.FieldSelection', 
    'radio' : 'instance.web.form.FieldRadio',
    'many2one' : 'instance.web.form.FieldMany2One',
    'many2onebutton' : 'instance.web.form.Many2OneButton',
    'many2many' : 'instance.web.form.FieldMany2Many',
    'many2many_tags' : 'instance.web.form.FieldMany2ManyTags',
    'many2many_kanban' : 'instance.web.form.FieldMany2ManyKanban',
    'one2many' : 'instance.web.form.FieldOne2Many',
    'one2many_list' : 'instance.web.form.FieldOne2Many',
    'reference' : 'instance.web.form.FieldReference',
    'boolean' : 'instance.web.form.FieldBoolean',
    'float' : 'instance.web.form.FieldFloat',
    'percentpie': 'instance.web.form.FieldPercentPie',
    'barchart': 'instance.web.form.FieldBarChart',
    'integer': 'instance.web.form.FieldFloat',
    'float_time': 'instance.web.form.FieldFloat',
    'progressbar': 'instance.web.form.FieldProgressBar',
    'image': 'instance.web.form.FieldBinaryImage',
    'binary': 'instance.web.form.FieldBinaryFile',
    'many2many_binary': 'instance.web.form.FieldMany2ManyBinaryMultiFiles',
    'statusbar': 'instance.web.form.FieldStatus',
    'monetary': 'instance.web.form.FieldMonetary',
    'many2many_checkboxes': 'instance.web.form.FieldMany2ManyCheckBoxes',
    'x2many_counter': 'instance.web.form.X2ManyCounter',
    'priority':'instance.web.form.Priority',
    'kanban_state_selection':'instance.web.form.KanbanSelection',
    'statinfo': 'instance.web.form.StatInfo',

Tuesday, 21 March 2017

What is the different between col and colspan?

Every form view container (form itself, group, page, I think there are more) in OpenERP consists of 4 columns to start with.
<form>
┌───┬───┬───┬───┐
│ 1 │ 2 │ 3 │ 4 │
└───┴───┴───┴───┘
</form> 
Every <field> takes 2 columns: label & input field
<field name="input" />
<field name="inpt2" />
┌───────┬───────┬───────┬───────┐
│ label │ input │ labl2 │ inpt2 │
└───────┴───────┴───────┴───────┘ 
With colspan, you can widen items.
<field name="inpt4" colspan="4"/>
<field name="input" />
<field name="inpt2" />
┌───────┬───────────────────────┐
│ labl4 │ inpt4_______________  │
├───────┼───────┬───────┬───────┤
│ label │ input │ labl2 │ inpt2 │
└───────┴───────┴───────┴───────┘

<field name="input" />
<field name="inpt4" colspan="4"/>
<field name="inpt2" />

┌───────┬───────┬───────┬───────┐
│ label │ input │       │       │
├───────┼───────┴───────┴───────┤
│ labl4 │ inpt4_______________  │
├───────┼───────┬───────┬───────┤
│ labl2 │ inpt2 │       │       │
└───────┴───────┴───────┴───────┘ 
When you add additional containers, like a page, you can tell OpenERP to use more or less columns.
<group col="2" colspan="2">
    <field name="a" />
    <field name="b" />
</group>
<group col="6" colspan="2">
    <field name="d" />
    <field name="e" />
    <field name="f" />
</group>
│       │       │                │                │
├───────┴───────┼────────────────┴────────────────┤
│ ┌────┬───┐    │  ┌────┬───┬────┬───┬────┬───┐   │
│ │ lb │ a │    │  │ lb │ d │ lb │ e │ lb │ f │   │
│ ├────┼───┤    │  └────┴───┴────┴───┴────┴───┘   │
│ │ lb │ b │    │                                 │
│ └────┴───┘    │                                 │
├───────┬───────┼────────────────┬────────────────┤
│       │       │                │                │