Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
5130 Lượt xem

i have already created a new category in the module of payroll and of course a new salary rule .. i have a class "avance" related to contract ( the contract have many of "avance"). it's linked like below :

class hr_contract(osv.osv):
_inherit = 'hr.contract'
_name = '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"
_description = "Avance"
 _columns = {
'montant_echeance': fields.function(_compute_montant, method=True, string='Montant d\'échéance'),
'line_contrat': fields.many2one('hr.contract', "contrat"),
}


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

i have a pyhton error of "amount_pyhton_compute" i need to extract the "montant_echeance" of the calss "avance" I need your help please !!!!!!!!!!!

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất
def _compute_montant(self, cr, uid, ids, field_name, arg, context={}):
    result = {}
    for id in ids:
        myself = self.browse(cr, uid, id, context=context)
        res = 0.0
        if myself:
            res = myself.montant_credit / myself.nbre_echeances
            result[id] = res
    return result

This function is in class hr_avance_pret. this function is correct. but my problème that i want to extract the "montant_echance" to use it in my salary rule. in the base module payroll i found you have to do like that to make a new salary rule like this exemple: (that's why i want to use the "amount_python_code")

<record id="hr_rule_secu" model="hr.salary.rule">
    <field name="name">Plafond Securite Sociale</field>
    <field name="code">SECU</field>
    <field name="sequence">1010</field>
    <field name="category_id" ref="SECU"/>
    <field name="appears_on_payslip" eval="False"/>
    <field name="condition_select">none</field>
    <field name="amount_select">code</field>
    <field name="amount_python_compute">result = contract.employee_id.company_id.plafond_secu</field>
</record>

Thank you for your apply!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Try: contract.montant_echeance

Ảnh đại diện
Huỷ bỏ
Tác giả

i still have the same error :-(

Câu trả lời hay nhất

Hi,

I can help you. Can you just tell me where you have defined the method "_compute_montant". Show me the code of the method.

and what is this amount_pyhton_compute? is it a method? if yes, tel me where you have got that

Ảnh đại diện
Huỷ bỏ
Tác giả

heeelp please!!

Câu trả lời hay nhất

The error is caused by the definition of the field 'amount_pyhton_compute' in the XML.

In your case, you probably want to create a function within hr_contract, which will calculate the value of what you want. At the moment I do not have access to my code, otherwise I might show you an example of how to do it.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
5039
12
thg 10 23
36117
0
thg 3 15
5076
4
thg 3 15
5256
2
thg 3 15
6308