connector-magento icon indicating copy to clipboard operation
connector-magento copied to clipboard

[FIX] Avoid overwrite name field over a company customer

Open kikopeiro opened this issue 9 years ago • 5 comments

When you are importing an update of an company customer the "company" field is not saved properly in field "name".

kikopeiro avatar Mar 18 '16 10:03 kikopeiro

Hi,

Thanks for your PR!

Could you give an example? With the current behaviour and your expected result.

guewen avatar Mar 18 '16 10:03 guewen

We have already created a company with magento_connector on Odoo.

This customer is configurated has follows in Magento... Customer information: there is not much to say Customer addess: is_billing_default --> True, company_field --> filled

The customer in ERP has been created has follows: Customer information --> name --> the information in Magento "company" field in the address object

If latter we update the customer in Magento,the information when we import to Odoo is not properly setted

Customer information: name --> the information in Magento "name" field in the address object

Thanks

kikopeiro avatar Mar 18 '16 11:03 kikopeiro

Ok, I think I get it. It should be corrected in the mapper, did you identify why the mapper set it the first time and not the second one?

guewen avatar Mar 18 '16 12:03 guewen

Mapper seems is working fine, _get_address_infos function in PartnerAddressBook. Here the code set the company field in customer name on Odoo

                company_mapper = self.unit_for(CompanyImportMapper,
                                               model='magento.res.partner')
                map_record = company_mapper.map_record(magento_record)
                parent = partner_binding.openerp_id.parent_id
                values = map_record.values(parent_partner=parent)
                **partner_binding.write(values)**

but after this "write" the partner information is being overwritten while executes function "run" for the address import.

    **addresses = self._get_address_infos(magento_partner_id,
                                        partner_binding_id)**
    for address_id, infos in addresses:
        importer = self.unit_for(MagentoImporter)
        **importer.run(address_id, address_infos=infos)**

kikopeiro avatar Mar 18 '16 12:03 kikopeiro

Still, you should probably not need to modify the importer, the address mapper could return the correct name at first place.

guewen avatar Mar 18 '16 15:03 guewen