Triggers in OpenERP

Asked by mm alam

Hi Every one,

I was wondering that, if there is any triggers concept in OpenERP. In related ERP systems such as Oracle, Triggers are very common being used on their forms.

In OpenERP, a related concept is the functional fields. However, Calculation with them is not that much perfect (as I have understood).

The reason is that, whenever, I try to save the data in a form (by pressing the Save Button), only then the values in different functional fields are calculated and saved in the corresponding fields.

Can we have some type of Pre-Trigger and Post-Trigger behavior in the sense that we can have a function which is called, as the control is being passed to the field on the form, Also, when the control is exited, we can also call another function.

I am following the following code, please help in identifying where I can change to get the aforementioned behavior:

class entrytest(osv.osv):

    def _get_company_currency(self, cr, uid, ids, field_name, arg, context={}):
        result = {}
        for rec in self.browse(cr, uid, ids, context):
            result[rec.id] = (rec.Percentage.id,rec.Percentage.Percentage)
        return result

    def _get_company_currency1(self, cr, uid, ids, field_name, arg, context={}):
        result = {}
        for rec in self.browse(cr, uid, ids, context):
            result[rec.id] = (rec.Percentage.id,rec.Percentage.CGPA)
        return result

    def _get_company_currency2(self, cr, uid, ids, field_name, arg, context={}):
        result = {}
        for rec in self.browse(cr, uid, ids, context):
            result[rec.id] = rec.interviewmarks + rec.Percentage.Percentage
        return result

    _name = "entrytest.entrytest"
    _description = "Entry Tesr Discription"
    _columns = {
        'name': fields.char('Name1', size=64),
        'Percentage': fields.many2one('student_qualification.student_qualification', 'Per'),
        'interviewmarks': fields.float('INterview Marks', required=True),
        'CGPA': fields.many2one('student_qualification.student_qualification', 'CGPA'),
        'line_id1': fields.function(_get_company_currency, method=True, type='many2one', relation='student_qualification.student_qualification', string='Percentage'),
        'line_id2': fields.function(_get_company_currency1, method=True, type='many2one', relation='student_qualification.student_qualification', string='CGPA'),
        'line_id3': fields.function(_get_company_currency2, method=True, type='many2one', relation='student_qualification.student_qualification', string='Total Marks'),

    }
entrytest()

Thanking you in advance.
Regards,
MM Alam

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Numérigraphe (numerigraphe) said :
#1

For client-side interactivity, OpenERP has client-side on-change events that can perform simple, presentation-only operations.
Please be aware that this should not be used for business processes or other complex computations, as OpenERP is a 3 tiers application.

On the server side, you can have server actions defined by administrators or advanced users.
And model object programmers can always intercept server-side database related actions by overriding the ORM methods.
The developer's documentation has it all described I think.
Lionel

Revision history for this message
xrg (xrg) said :
#2

On Tuesday 29 June 2010, you wrote:
> New question #116088 on OpenObject Server:
> https://answers.launchpad.net/openobject-server/+question/116088
>
> Hi Every one,
>
> I was wondering that, if there is any triggers concept in OpenERP. In
> related ERP systems such as Oracle, Triggers are very common being used on
> their forms.

Yes, there is such concept: you can inherit the write() method and put any
pre/post checking or calculation. See the code, this is common practice in
OpenERP.

Revision history for this message
Yogesh (yogeshwankhade43) said :
#3

How to call function of another class in our class in openerp

Revision history for this message
Yogesh (yogeshwankhade43) said :
#4

How to call function of another class in our class in openerp

Can you help with this problem?

Provide an answer of your own, or ask mm alam for more information if necessary.

To post a message you must log in.