Make partner_default_properties multi-company proof by storing defaults on res.company

This commit is contained in:
Kristof Bernaert
2026-04-14 11:13:48 +02:00
parent 8a635f1805
commit d8c0469dc3
5 changed files with 79 additions and 28 deletions
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from odoo import models
from .res_config_settings import PARAM_FISCAL_POSITION, PARAM_PAYMENT_TERM
class ResPartner(models.Model):
@@ -8,14 +7,12 @@ class ResPartner(models.Model):
def default_get(self, fields_list):
res = super().default_get(fields_list)
ICP = self.env['ir.config_parameter'].sudo()
company = self.env.company
fp_id = ICP.get_param(PARAM_FISCAL_POSITION)
if fp_id:
res['property_account_position_id'] = int(fp_id)
if company.customer_fiscal_position_id:
res['property_account_position_id'] = company.customer_fiscal_position_id.id
pt_id = ICP.get_param(PARAM_PAYMENT_TERM)
if pt_id:
res['property_payment_term_id'] = int(pt_id)
if company.customer_payment_term_id:
res['property_payment_term_id'] = company.customer_payment_term_id.id
return res