From 6ae4a666f3fb0e107d962efceceef9d10133af45 Mon Sep 17 00:00:00 2001 From: Maxime Richez Date: Mon, 11 Oct 2021 15:35:46 +0200 Subject: [PATCH] Add field access on referential document issue10269 review332861003 --- party.py | 12 ++++++++++++ party.xml | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/party.py b/party.py index ad92a09c12..ca7fb2c4a4 100644 --- a/party.py +++ b/party.py @@ -5,6 +5,7 @@ from trytond.model import ModelSQL, fields from trytond.pyson import Eval from trytond.pool import PoolMeta, Pool from trytond.tools.multivalue import migrate_property +from trytond.transaction import Transaction from trytond.modules.company.model import ( CompanyMultiValueMixin, CompanyValueMixin) @@ -31,6 +32,17 @@ class Party(CompanyMultiValueMixin, metaclass=PoolMeta): price_list = config.get_multivalue('sale_price_list', **pattern) return price_list.id if price_list else None + @classmethod + def copy(cls, parties, default=None): + context = Transaction().context + default = default.copy() if default else {} + if context.get('_check_access'): + fields = ['sale_price_lists', 'sale_price_list'] + default_values = cls.default_get(fields, with_rec_name=False) + for fname in fields: + default.setdefault(fname, default_values.get(fname)) + return super().copy(parties, default=default) + class PartySalePriceList(ModelSQL, CompanyValueMixin): "Party Sale Price List" diff --git a/party.xml b/party.xml index dd6f1fd0c2..173fe57028 100644 --- a/party.xml +++ b/party.xml @@ -10,5 +10,29 @@ this repository contains the full copyright notices and license terms. --> party_form + + + + + + + + + + + + + + + + + + + + + + + +