[FIX] account: soften the constraint on company_id on partner's fp
Have a partner with company_id = False Your user is currently in company A Before this commit, only FPs with no company id could be set on the partner After this commit, FP without company or belonging to company A are available The drawback is that since this computation takes place in an onchange, when you first arrive on the partner no filter is applied and you can choose whatever FP that appear This might cause access errors when it is misued related to #24256 closes #24507
This commit is contained in:
@@ -394,8 +394,7 @@ class ResPartner(models.Model):
|
||||
required=True)
|
||||
property_account_position_id = fields.Many2one('account.fiscal.position', company_dependent=True,
|
||||
string="Fiscal Position",
|
||||
help="The fiscal position will determine taxes and accounts used for the partner.", oldname="property_account_position",
|
||||
domain="[('company_id', 'in', [company_id, False])]")
|
||||
help="The fiscal position will determine taxes and accounts used for the partner.", oldname="property_account_position")
|
||||
property_payment_term_id = fields.Many2one('account.payment.term', company_dependent=True,
|
||||
string='Customer Payment Terms',
|
||||
help="This payment term will be used instead of the default one for sales orders and customer invoices", oldname="property_payment_term")
|
||||
@@ -445,5 +444,9 @@ class ResPartner(models.Model):
|
||||
|
||||
@api.onchange('company_id')
|
||||
def _onchange_company_id(self):
|
||||
company = self.env['res.company']
|
||||
if self.company_id:
|
||||
return {'domain': {'property_account_position_id': [('company_id', 'in', [self.company_id.id, False])]}}
|
||||
company = self.company_id
|
||||
else:
|
||||
company = self.env.user.company_id
|
||||
return {'domain': {'property_account_position_id': [('company_id', 'in', [company.id, False])]}}
|
||||
|
||||
Reference in New Issue
Block a user