Search code examples
pythonautomationodooodoo-12

How to edit variable Odoo


When a user orders a subscription we want to update their price list.

The ID of the current price list of the user that ordered a subscription is this:

env['res.partner'].search([['id', '=', record.partner_id.id]]).property_product_pricelist.id

But I now want to change that pricelist, how do I change the ID value? Should I update any other values like the name or is it changed automatically?


Solution

  • The code I needed was this line:

    env['res.partner'].search([['id', '=', record.partner_id.id]]).write({'property_product_pricelist': my_pricelist_id})