Odoo Help

0

extraction attribute with: amount_python_compute

By
myriam
on 5/21/13, 2:12 PM 1,887 views

I'm working on the payroll module and on my own module, this data file is the one of paryroll , i'm trying to add another category ... because I need a category with a calculation rule that retrieves the value of the amount "montant"of class.

This category belongs to that one of the deduction. I need it to compute the payslip.

<record id="hr_AVANCE" model="hr.salary.rule.category">
    <field name="name">Remboursement de Prêts</field>
    <field name="code">AVANCE</field>
<field name="parent_id" ref="hr_payroll.DED"/>

</record>

record id="hr_payroll.avance" model="hr.salary.rule">
    <field name="name">Remboursement des Prêts</field>
    <field name="code">AVANCE PRET</field>
    <field name="sequence">100000</field>
    <field name="category_id" ref="hr_AVANCE"/>
    <field name="condition_select">none</field>
    <field name="amount_select">code</field>
    <field name="amount_python_compute">**result = contract.line_av_ids.montant<**/field>
    <field name="appears_on_payslip" eval="False"/>
    <field name="note">la valeur des avances et des prêts.</field>
</record>

python:

class hr_contract(osv.osv):


_inherit = 'hr.contract'

_columns = {
    'line_av_ids': fields.one2many('hr.avance.pret', 'avance_id', 'Avance et Prêt'),
}

hr_contract()

class hr_avance_pret(osv.osv):
_name = "hr.avance.pret"
 _columns = {

    'employee_id': fields.many2one('hr.employee', "Employee", select=True, readonly=True),

    'line_ids': fields.one2many('hr.line.echeancier', 'line_id', 'ligne d\'échéance', required=False),
    'avance_id': fields.integer('ID'),
}

hr_avance_pret()

class hr_line_echeancier(osv.osv):
_name = "hr.line.echeancier"
_description = "Echeancier"

_columns = {
    'line_id': fields.many2one('hr.avance.pret', "ligne d\'échéancier"),

    **'montant': fields.float('Montant'),**
}

hr_line_echeancier()

this code is in my data file:

<field name="amount_python_compute">result = contract.line_av_ids.montant</field>

but i recieve ERROR !! hr_avance_pret and hr_line_echeancier are in a class in another module. these two classes are related with CONTRACT. I need to have the "montant" attribute of the class hr_line_echeancier. I don't know how should I call this class here in the file data... How should i do this please !!!

Thank you .

heeelllp pleaaaseeeeeeee !!!!

myriam
on 5/22/13, 12:56 PM
0
myriam
On 5/22/13, 7:02 AM

but my problem is hier:
<field name="amount_python_compute">result = contract.line_av_ids.montant</field> I don't know how to extract the value of the amount of "hr_echeancier" table through the table "hr_avance_pret" which is related to "contract" by one2many. Thank you so much .

0
le_dilem
On 5/21/13, 4:17 PM

Pour Appeler une classe : La Methode Browse. link text

Exemple :

products = self.pool.get('product.product').browse(cr, uid, product, context=context)

Ici je parcours la table produit j'ai comme ID product.pour faire le lien

si je veux utiliser un champ :

products.reference par exemple

et la je peux l'utiliser dans une autre calsse Slts

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 5/21/13, 2:12 PM
Seen: 1887 times
Last updated: 3/16/15, 8:10 AM