Make partner_default_properties multi-company proof by storing defaults on res.company
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * partner_default_properties
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 16.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2026-04-14 00:00+0000\n"
|
||||||
|
"PO-Revision-Date: 2026-04-14 00:00+0100\n"
|
||||||
|
"Last-Translator: \n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"Language: nl_BE\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model:ir.model.fields,field_description:partner_default_properties.field_res_company__customer_fiscal_position_id
|
||||||
|
#: model:ir.model.fields,field_description:partner_default_properties.field_res_config_settings__customer_fiscal_position_id
|
||||||
|
msgid "Default Customer Fiscal Position"
|
||||||
|
msgstr "Standaard fiscale positie"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model:ir.model.fields,field_description:partner_default_properties.field_res_company__customer_payment_term_id
|
||||||
|
#: model:ir.model.fields,field_description:partner_default_properties.field_res_config_settings__customer_payment_term_id
|
||||||
|
msgid "Default Customer Payment Terms"
|
||||||
|
msgstr "Standaard betalingstermijnen"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model_terms:ir.ui.view,arch_db:partner_default_properties.res_config_settings_view_form_inherit_partner_defaults
|
||||||
|
msgid "Default Fiscal Position"
|
||||||
|
msgstr "Standaard fiscale positie"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model_terms:ir.ui.view,arch_db:partner_default_properties.res_config_settings_view_form_inherit_partner_defaults
|
||||||
|
msgid "Default Payment Terms"
|
||||||
|
msgstr "Standaard betalingstermijnen"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model_terms:ir.ui.view,arch_db:partner_default_properties.res_config_settings_view_form_inherit_partner_defaults
|
||||||
|
msgid "Default Customer Properties"
|
||||||
|
msgstr "Standaard klanteigenschappen"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model_terms:ir.ui.view,arch_db:partner_default_properties.res_config_settings_view_form_inherit_partner_defaults
|
||||||
|
msgid "Applied automatically to new customers"
|
||||||
|
msgstr "Automatisch toegepast op nieuwe klanten"
|
||||||
|
|
||||||
|
#. module: partner_default_properties
|
||||||
|
#: model_terms:ir.ui.view,arch_db:partner_default_properties.res_config_settings_view_form_inherit_partner_defaults
|
||||||
|
msgid "Values set here are company-specific."
|
||||||
|
msgstr "De hier ingestelde waarden zijn bedrijfsspecifiek."
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from . import res_company
|
||||||
from . import res_config_settings
|
from . import res_config_settings
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResCompany(models.Model):
|
||||||
|
_inherit = 'res.company'
|
||||||
|
|
||||||
|
customer_fiscal_position_id = fields.Many2one(
|
||||||
|
comodel_name='account.fiscal.position',
|
||||||
|
string='Default Customer Fiscal Position',
|
||||||
|
)
|
||||||
|
customer_payment_term_id = fields.Many2one(
|
||||||
|
comodel_name='account.payment.term',
|
||||||
|
string='Default Customer Payment Terms',
|
||||||
|
)
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
|
|
||||||
PARAM_FISCAL_POSITION = 'partner_default_properties.fiscal_position_id'
|
|
||||||
PARAM_PAYMENT_TERM = 'partner_default_properties.payment_term_id'
|
|
||||||
|
|
||||||
|
|
||||||
class ResConfigSettings(models.TransientModel):
|
class ResConfigSettings(models.TransientModel):
|
||||||
_inherit = 'res.config.settings'
|
_inherit = 'res.config.settings'
|
||||||
@@ -11,25 +8,12 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
customer_fiscal_position_id = fields.Many2one(
|
customer_fiscal_position_id = fields.Many2one(
|
||||||
comodel_name='account.fiscal.position',
|
comodel_name='account.fiscal.position',
|
||||||
string='Default Fiscal Position',
|
string='Default Fiscal Position',
|
||||||
|
related='company_id.customer_fiscal_position_id',
|
||||||
|
readonly=False,
|
||||||
)
|
)
|
||||||
customer_payment_term_id = fields.Many2one(
|
customer_payment_term_id = fields.Many2one(
|
||||||
comodel_name='account.payment.term',
|
comodel_name='account.payment.term',
|
||||||
string='Default Payment Terms',
|
string='Default Payment Terms',
|
||||||
|
related='company_id.customer_payment_term_id',
|
||||||
|
readonly=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_values(self):
|
|
||||||
res = super().get_values()
|
|
||||||
ICP = self.env['ir.config_parameter'].sudo()
|
|
||||||
fp_id = ICP.get_param(PARAM_FISCAL_POSITION)
|
|
||||||
pt_id = ICP.get_param(PARAM_PAYMENT_TERM)
|
|
||||||
res.update({
|
|
||||||
'customer_fiscal_position_id': int(fp_id) if fp_id else False,
|
|
||||||
'customer_payment_term_id': int(pt_id) if pt_id else False,
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
def set_values(self):
|
|
||||||
super().set_values()
|
|
||||||
ICP = self.env['ir.config_parameter'].sudo()
|
|
||||||
ICP.set_param(PARAM_FISCAL_POSITION, self.customer_fiscal_position_id.id or False)
|
|
||||||
ICP.set_param(PARAM_PAYMENT_TERM, self.customer_payment_term_id.id or False)
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from odoo import models
|
from odoo import models
|
||||||
from .res_config_settings import PARAM_FISCAL_POSITION, PARAM_PAYMENT_TERM
|
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
@@ -8,14 +7,12 @@ class ResPartner(models.Model):
|
|||||||
|
|
||||||
def default_get(self, fields_list):
|
def default_get(self, fields_list):
|
||||||
res = super().default_get(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 company.customer_fiscal_position_id:
|
||||||
if fp_id:
|
res['property_account_position_id'] = company.customer_fiscal_position_id.id
|
||||||
res['property_account_position_id'] = int(fp_id)
|
|
||||||
|
|
||||||
pt_id = ICP.get_param(PARAM_PAYMENT_TERM)
|
if company.customer_payment_term_id:
|
||||||
if pt_id:
|
res['property_payment_term_id'] = company.customer_payment_term_id.id
|
||||||
res['property_payment_term_id'] = int(pt_id)
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user