Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2290 Представления

When adding the CSV file with multiple parent_id to the hr.profession.category model this error appears:

Exception: Module loading ptplus_hr_payroll failed: file ptplus_hr_payroll/data/hr.profession.category.csv could not be processed: No matching record found for name 'Oficiais das Forças Armadas' in field 'Parent Category'

The data file contains the following table:

id,name,parent_id

hr_profession_category_1,Profissões das Forças Armadas,

hr_profession_category_2,Oficiais das Forças Armadas,Profissões das Forças Armadas

hr_profession_category_3,Oficial de Marinha,Oficiais das Forças Armadas

The model code for hr.profession.category looks like this:

class HrProfessionCategory(models.Model):
    _name = "hr.profession.category"
    _description = "Hr Profession Category"
    _parent_name = "parent_id"
    _parent_store = True
    _rec_name = 'complete_name'
    _order = 'complete_name'

    name = fields.Char('Name', index=True, required=True)
    complete_name = fields.Char(
        'Complete Name', compute='_compute_complete_name',
        store=True)
    parent_id = fields.Many2one('hr.profession.category', 'Parent Category', index=True, ondelete='cascade')
    parent_path = fields.Char(index=True)
    child_id = fields.One2many('hr.profession.category', 'parent_id', 'Child Categories')

    @api.depends('name', 'parent_id.complete_name')
    def _compute_complete_name(self):
        for category in self:
            if category.parent_id:
                category.complete_name = '%s / %s' % (category.parent_id.complete_name, category.name)
            else:
                category.complete_name = category.name

Can anyone help me decipher the problem?

Аватар
Отменить
Лучший ответ

Hello Tiago Rangel

odoo import features try to find similar parent(parent_id) record based on name field. But you have defined "_rec_name = 'complete_name'" means that your name field would be complete_name so that record search value in complete_name column and it is not match.

There multiple ways to do this.

1) you can change your _rec_name ="name" or remove  "_rec_name = 'complete_name'", this way your csv parent_id name will be match with name field

2) you can update your csv with extena id value for parent_id as below

"id","name","parent_id"
"hr_profession_category_1","Profissões das Forças Armadas",""
"hr_profession_category_2","Oficiais das Forças Armadas","hr_profession_category_1"
"hr_profession_category_3","Oficial de Marinha","hr_profession_category_2"

you have to choose "Show fields of relation fields(advance)" to import parent_id with external id as below screenshot.

Records import successfully !!



Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat


Аватар
Отменить
Related Posts Ответы Просмотры Активность
3
сент. 25
3310
0
авг. 25
840
1
авг. 25
3063
2
июл. 25
8708
2
июл. 25
5070