Merge branch 'master-branch' into 'master'

[FIX]: Issue : 85 : Branch.

See merge request flectra-hq/flectra!88
This commit is contained in:
Parthiv Patel 2018-06-29 11:37:11 +00:00
commit 823c7409a5
4 changed files with 29 additions and 2 deletions

View File

@ -1501,7 +1501,6 @@ class AccountMoveLine(models.Model):
domain = domain or [] domain = domain or []
if not isinstance(domain, (list, tuple)): if not isinstance(domain, (list, tuple)):
domain = safe_eval(domain) domain = safe_eval(domain)
date_field = 'date' date_field = 'date'
if context.get('aged_balance'): if context.get('aged_balance'):
date_field = 'date_maturity' date_field = 'date_maturity'
@ -1525,6 +1524,9 @@ class AccountMoveLine(models.Model):
if context.get('company_id'): if context.get('company_id'):
domain += [('company_id', '=', context['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: if 'company_ids' in context:
domain += [('company_id', 'in', context['company_ids'])] domain += [('company_id', 'in', context['company_ids'])]

View File

@ -3,7 +3,7 @@
{ {
'name': 'Branch & Company Mixin', 'name': 'Branch & Company Mixin',
'version': '1.0', 'version': '1.1',
'category': 'Discuss', 'category': 'Discuss',
'author': 'FlectraHQ', 'author': 'FlectraHQ',
'sequence': 25, 'sequence': 25,

View File

@ -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)

View File

@ -1,8 +1,20 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from flectra import api, fields, models from flectra import api, fields, models
from flectra import SUPERUSER_ID
# from flectra.exceptions import ValidationError # 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): class Company(models.Model):
_name = "res.company" _name = "res.company"
@ -116,6 +128,11 @@ class Users(models.Model):
compute='_compute_branches_count', compute='_compute_branches_count',
string="Number of Companies", default=_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 # To do : Check with all base module test cases
# @api.multi # @api.multi
# @api.constrains('default_branch_id', 'branch_ids') # @api.constrains('default_branch_id', 'branch_ids')