Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
4 Odpovědi
4714 Zobrazení

i have this code in my data file:

<field name="amount_python_compute">result = hr_line_echeancier.montant</field>

but i recieve ERROR !! hr_line_echeancier is in a class in another module. 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 .

Avatar
Zrušit

is there any link between contract and this modules or payslip and this module?? ,,,

Autor

it's linked with contract: class hr_contract(osv.osv):

_inherit = 'hr.contract'

_columns = {
    'line_ech_ids': fields.one2many('hr.line.echeancier', 'line_id', 'ligne Echéancier'),
}

hr_contract()

Autor

SOS @Sandeep !!

Nejlepší odpověď

Hey myriam

now i understand as you commented above that this is liked to contract as one2many field so now just paste this my below code in amount_python_compute field

 a=0
 for i in contract.line_ech_ids:
     a=a+i.montant
 result=a

note: please be in mind this object (hr.line.echeancier) should be liked to contract as one2many field then this above code will work fine

thanks
sandeep

Avatar
Zrušit
Autor

Sorry !! but it didn't work for me, it generates an error for this code....

Autor

due to some design changes I had to make some changes in the link between tables and here is the problem explained otherwise http://help.openerp.com/question/17740/extraction-attribute-with-amount_python_compute/

Nejlepší odpověď

you uninstall or remove the depends of thats module surely it will work.

Avatar
Zrušit
Autor Nejlepší odpověď

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 = hr.line.echeancier.montant</field>
        <field name="appears_on_payslip" eval="False"/>
        <field name="note">la valeur des avances et des prêts.</field>
    </record>

pyhton:

class hr_line_echeancier(osv.osv):
    _name = "hr.line.echeancier"
    _description = "Echeancier"
 _columns = {
        'line_id': fields.many2one('hr.avance.pret', "ligne d\'échéancier"),
        'date_ech': fields.date('Date d\'échéance',
                                states={'draft': [('readonly', False)], 'confirm': [('readonly', False)]}, select=True),
        'montant': fields.float('Montant'),

    }

Thank you so much ..

Avatar
Zrušit

is it liked to employee ?? i mean hr.line.echeancier

Autor

i want something like this one :<field name="amount_python_compute">result = contract.wage</field>but i can't find the way to do it with my own class..! please heeeellp!!! thank you for your apply

Autor

heeeellppp !! pleaseee

hey Myrian , you can use only contratc payslip, time and some object there ,,, you can't use your own object there for that case you will have to register your own object in compute button method

Autor

Thank you ...

Autor

it's linked to class contarct : _inherit = 'hr.contract'

_columns = { 'line_ech_ids': fields.one2many('hr.line.echeancier', 'line_id', 'ligne Echéancier'), } heeelp pleaaaseeeeeeee :-(

Nejlepší odpověď

Hi,

In file data.xml all data are defined in a static way or relationships between class. so you can do :

<field name="amount_python_compute">your value amount</field>
Avatar
Zrušit
Autor

to compute my payslip i need to have dynamic values and not static ... so i should do something like in the file data of the basic payroll (employee.marital)or ( contract.wage)..... Thank you

Related Posts Odpovědi Zobrazení Aktivita
2
zář 23
4493
12
říj 23
35704
4
bře 15
4801
2
bře 15
5908
0
bře 15
4521