[FIX] account: allow creating move in branch without parent access
When a user only has access to a branch and not to the parent, he can not create a new customer invoice or vendor bill, since we need to check the lock date on all ancestor companies (where the user might not have access to). This fix allows the user to create a new customer invoice or vendor bill again when only having access to a branch. Furthermore, in the above case we are also unable to assign a partner on the invoice/bill, since we are checking properties that might belong to an ancestor company we don't have access to. We also fixed that here, so a partner can be selected. task-3503204 Part-of: odoo/odoo#138942
This commit is contained in:
@@ -1737,7 +1737,7 @@ class AccountMove(models.Model):
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def _onchange_partner_id(self):
|
||||
self = self.with_company(self.journal_id.company_id)
|
||||
self = self.with_company(self.journal_id.company_id._accessible_branches()[:1])
|
||||
|
||||
warning = {}
|
||||
if self.partner_id:
|
||||
|
||||
@@ -356,7 +356,8 @@ class ResCompany(models.Model):
|
||||
if self.user_has_groups('account.group_account_manager'):
|
||||
lock_date = self.fiscalyear_lock_date or date.min
|
||||
if self.parent_id:
|
||||
lock_date = max(lock_date, self.parent_id._get_user_fiscal_lock_date())
|
||||
# We need to use sudo, since we might not have access to a parent company.
|
||||
lock_date = max(lock_date, self.sudo().parent_id._get_user_fiscal_lock_date())
|
||||
return lock_date
|
||||
|
||||
def _get_violated_lock_dates(self, accounting_date, has_tax):
|
||||
|
||||
Reference in New Issue
Block a user