[FIX]: Issue : 85 : Branch.
This commit is contained in:
parent
e423538eb3
commit
cb0640a320
@ -1501,7 +1501,6 @@ class AccountMoveLine(models.Model):
|
||||
domain = domain or []
|
||||
if not isinstance(domain, (list, tuple)):
|
||||
domain = safe_eval(domain)
|
||||
|
||||
date_field = 'date'
|
||||
if context.get('aged_balance'):
|
||||
date_field = 'date_maturity'
|
||||
@ -1525,6 +1524,9 @@ class AccountMoveLine(models.Model):
|
||||
if context.get('company_id'):
|
||||
domain += [('company_id', '=', context['company_id'])]
|
||||
|
||||
if context.get('branch_id', False):
|
||||
domain += [('branch_id', '=', context['branch_id'][0])]
|
||||
|
||||
if 'company_ids' in context:
|
||||
domain += [('company_id', 'in', context['company_ids'])]
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
'name': 'Branch & Company Mixin',
|
||||
'version': '1.0',
|
||||
'version': '1.1',
|
||||
'category': 'Discuss',
|
||||
'author': 'FlectraHQ',
|
||||
'sequence': 25,
|
||||
|
@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import flectra
|
||||
|
||||
def migrate(cr, version):
|
||||
registry = flectra.registry(cr.dbname)
|
||||
from flectra.addons.base_branch_company.models.res_branch import \
|
||||
migrate_company_branch
|
||||
migrate_company_branch(cr, registry)
|
@ -1,8 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flectra import api, fields, models
|
||||
from flectra import SUPERUSER_ID
|
||||
# from flectra.exceptions import ValidationError
|
||||
|
||||
def migrate_company_branch(cr, registry):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
company = env.ref('base.main_company')
|
||||
company.write({'branch_id': env.ref('base_branch_company.data_branch_1').id})
|
||||
cr.commit()
|
||||
user_ids = env['res.users'].search([])
|
||||
for user_id in user_ids:
|
||||
if not user_id.user_has_groups('base_branch_company.group_multi_branch'):
|
||||
user_id.sudo().write({'default_branch_id': user_id.company_id.branch_id.id,
|
||||
'branch_ids': [(6, 0, [user_id.company_id.branch_id.id])]})
|
||||
cr.commit()
|
||||
|
||||
class Company(models.Model):
|
||||
_name = "res.company"
|
||||
@ -116,6 +128,11 @@ class Users(models.Model):
|
||||
compute='_compute_branches_count',
|
||||
string="Number of Companies", default=_branches_count)
|
||||
|
||||
@api.onchange('company_id')
|
||||
def _onchange_address(self):
|
||||
self.default_branch_id = self.company_id.branch_id.id
|
||||
self.branch_ids = [(4, self.company_id.branch_id.id)]
|
||||
|
||||
# To do : Check with all base module test cases
|
||||
# @api.multi
|
||||
# @api.constrains('default_branch_id', 'branch_ids')
|
||||
|
Loading…
Reference in New Issue
Block a user