This is too late, but anyways, the issue is probably that the `property_account_payable_id` is a company specific value, meaning that accessing that property will always return the value for the current user's company.
Even if that user is the superuser aka OdooBot, it will return the value for that user's company.
A workaround is to read the value from the `ir.property` directly, maybe something like:
sudo_self = self.sudo()
ir_property = sudo_self.env['ir.property'].search([('name', '=', 'property_account_payable_id'), ('res_id', '=', 'res.partner,{}'.format(partner_id.id)), ('company_id', '=', company_id.id)])
target_account_id = (ir_property.value_reference.split(',')[1])
target_account = sudo_self.env['account.account'].browse(target_account_id)
More details:
The `property_account_payable_id` is not a normal field, it is defined with something like this:
property_account_payable_id = fields.Many2one('account.account', company_dependent=True,
string="Account Payable", oldname="property_account_payable",
domain="[('internal_type', '=', 'payable'), ('deprecated', '=', False)]",
help="This account will be used instead of the default one as the payable account for the current partner",
required=True)
the `company_dependent` argument means that this field can be set for each company with a different value. Thus it will not be recorded as a normal column in the table in the database. Instead it will create a new record in a separate table called `ir_property`.
The table `ir_property` includes columns that can help to identify the value for each company, see these columns in the database (name, res_id, value_reference, company_id).
You can retrieve the value you want, but it will just need more effort.
BTW, don't try to change the company of the superuser to be able to read the fields you want. This is an opinion not a fact, but it is probably dangerous to do so.