[REF] branch: remove old files, temp disable systray
This commit is contained in:
parent
5541d4adc9
commit
875512ca6b
|
|
@ -39,11 +39,11 @@
|
||||||
'views/stock_warehouse.xml',
|
'views/stock_warehouse.xml',
|
||||||
],
|
],
|
||||||
|
|
||||||
'assets': {
|
# 'assets': {
|
||||||
'web.assets_backend': [
|
# 'web.assets_backend': [
|
||||||
'branch/static/src/**/*',
|
# 'branch/static/src/**/*',
|
||||||
]
|
# ]
|
||||||
},
|
# },
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
'live_test_url':'https://youtu.be/hi1b8kH5Z94',
|
'live_test_url':'https://youtu.be/hi1b8kH5Z94',
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
# -*- encoding: utf-8 -*-
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
|
||||||
|
|
||||||
from odoo import SUPERUSER_ID
|
|
||||||
from odoo import api
|
|
||||||
|
|
||||||
|
|
||||||
def post_init_hook(cr, registry):
|
|
||||||
"""
|
|
||||||
website menu hide
|
|
||||||
"""
|
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
||||||
cr.execute("""
|
|
||||||
update ir_model_data set noupdate=False where
|
|
||||||
model ='ir.rule' """)
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
import time
|
|
||||||
|
|
||||||
class AccountBankStatement(models.Model):
|
|
||||||
_inherit = 'account.bank.statement'
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
def _get_opening_balance(self, journal_id):
|
|
||||||
curr_user_id = self.env['res.users'].browse(self.env.context.get('uid', False))
|
|
||||||
last_bnk_stmt = self.search([('journal_id', '=', journal_id),('branch_id','=',curr_user_id.branch_id.id)], limit=1)
|
|
||||||
if last_bnk_stmt:
|
|
||||||
return last_bnk_stmt.balance_end
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self,fields):
|
|
||||||
res = super(AccountBankStatement, self).default_get(fields)
|
|
||||||
branch_id = False
|
|
||||||
if self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
res.update({
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
def button_confirm_bank(self):
|
|
||||||
self._balance_check()
|
|
||||||
statements = self.filtered(lambda r: r.state == 'open')
|
|
||||||
for statement in statements:
|
|
||||||
moves = self.env['account.move']
|
|
||||||
for st_line in statement.line_ids:
|
|
||||||
#upon bank statement confirmation, look if some lines have the account_id set. It would trigger a journal entry
|
|
||||||
#creation towards that account, with the wanted side-effect to skip that line in the bank reconciliation widget.
|
|
||||||
st_line.fast_counterpart_creation()
|
|
||||||
if not st_line.account_id and not st_line.journal_entry_ids.ids and not st_line.statement_id.currency_id.is_zero(st_line.amount):
|
|
||||||
raise UserError(_('All the account entries lines must be processed in order to close the statement.'))
|
|
||||||
for aml in st_line.journal_entry_ids:
|
|
||||||
aml.branch_id = st_line.branch_id.id
|
|
||||||
moves |= aml.move_id
|
|
||||||
|
|
||||||
if moves:
|
|
||||||
if self._context.get('session'):
|
|
||||||
session = self._context.get('session')
|
|
||||||
for move in moves:
|
|
||||||
move.branch_id =session.branch_id.id
|
|
||||||
for line in move.line_ids:
|
|
||||||
line.branch_id = session.branch_id.id
|
|
||||||
moves.filtered(lambda m: m.state != 'posted').post()
|
|
||||||
statement.write({'branch_id': statement.pos_session_id.branch_id.id})
|
|
||||||
else:
|
|
||||||
moves.filtered(lambda m: m.state != 'posted').post()
|
|
||||||
for move in moves:
|
|
||||||
for move_line in move.line_ids:
|
|
||||||
line_branch = move_line.branch_id.id
|
|
||||||
move.branch_id = line_branch
|
|
||||||
|
|
||||||
|
|
||||||
statement.message_post(body=_('Statement %s confirmed, journal items were created.') % (statement.name,))
|
|
||||||
|
|
||||||
statements.write({'state': 'confirm', 'date_done': time.strftime("%Y-%m-%d %H:%M:%S")})
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class account_bank_statement_line(models.Model):
|
|
||||||
|
|
||||||
_inherit = 'account.bank.statement.line'
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(account_bank_statement_line, self).default_get(default_fields)
|
|
||||||
branch_id = False
|
|
||||||
if self._context.get('branch_id'):
|
|
||||||
branch_id = self._context.get('branch_id')
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
res.update({
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string='Branch')
|
|
||||||
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
from odoo.tools.float_utils import float_compare
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AccountMove(models.Model):
|
|
||||||
_inherit = 'account.move'
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(AccountMove, self).default_get(default_fields)
|
|
||||||
branch_id = False
|
|
||||||
|
|
||||||
if self._context.get('branch_id'):
|
|
||||||
branch_id = self._context.get('branch_id')
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
res.update({
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
||||||
|
|
||||||
class AccountMoveLine(models.Model):
|
|
||||||
_inherit = 'account.move.line'
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(AccountMoveLine, self).default_get(default_fields)
|
|
||||||
branch_id = False
|
|
||||||
|
|
||||||
if self._context.get('branch_id'):
|
|
||||||
branch_id = self._context.get('branch_id')
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
if self.move_id.branch_id :
|
|
||||||
branch_id = self.move_id.branch_id.id
|
|
||||||
res.update({'branch_id' : branch_id})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch",related="move_id.branch_id",store=True)
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
MAP_INVOICE_TYPE_PARTNER_TYPE = {
|
|
||||||
'out_invoice': 'customer',
|
|
||||||
'out_refund': 'customer',
|
|
||||||
'in_invoice': 'supplier',
|
|
||||||
'in_refund': 'supplier',
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccountPayment(models.Model):
|
|
||||||
_inherit = 'account.payment'
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, fields):
|
|
||||||
rec = super(AccountPayment, self).default_get(fields)
|
|
||||||
invoice_defaults = self.reconciled_invoice_ids
|
|
||||||
if invoice_defaults and len(invoice_defaults) == 1:
|
|
||||||
invoice = invoice_defaults[0]
|
|
||||||
rec['branch_id'] = invoice.branch_id.id
|
|
||||||
return rec
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class ResPartnerIn(models.Model):
|
|
||||||
_inherit = 'res.partner'
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(ResPartnerIn, self).default_get(default_fields)
|
|
||||||
if self.env.user.branch_id:
|
|
||||||
res.update({
|
|
||||||
'branch_id' : self.env.user.branch_id.id or False
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class ProductTemplateIn(models.Model):
|
|
||||||
_inherit = 'product.template'
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(ProductTemplateIn, self).default_get(default_fields)
|
|
||||||
if self.env.user.branch_id:
|
|
||||||
res.update({
|
|
||||||
'branch_id' : self.env.user.branch_id.id or False
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class purchase_order(models.Model):
|
|
||||||
|
|
||||||
_inherit = 'purchase.order.line'
|
|
||||||
|
|
||||||
|
|
||||||
def _prepare_account_move_line(self, move=False):
|
|
||||||
result = super(purchase_order, self)._prepare_account_move_line(move)
|
|
||||||
result.update({
|
|
||||||
'branch_id' : self.order_id.branch_id.id or False,
|
|
||||||
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(purchase_order, self).default_get(default_fields)
|
|
||||||
branch_id = False
|
|
||||||
if self._context.get('branch_id'):
|
|
||||||
branch_id = self._context.get('branch_id')
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
res.update({'branch_id' : branch_id})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
|
||||||
|
|
||||||
|
|
||||||
def _prepare_stock_moves(self, picking):
|
|
||||||
result = super(purchase_order, self)._prepare_stock_moves(picking)
|
|
||||||
|
|
||||||
branch_id = False
|
|
||||||
if self.branch_id:
|
|
||||||
branch_id = self.branch_id.id
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
for res in result:
|
|
||||||
res.update({'branch_id' : branch_id})
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
class PurchaseOrder(models.Model):
|
|
||||||
_inherit = 'purchase.order'
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self,fields):
|
|
||||||
res = super(PurchaseOrder, self).default_get(fields)
|
|
||||||
branch_id = picking_type_id = False
|
|
||||||
|
|
||||||
if self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
if branch_id:
|
|
||||||
branched_warehouse = self.env['stock.warehouse'].search([('branch_id','=',branch_id)])
|
|
||||||
if branched_warehouse:
|
|
||||||
picking_type_id = branched_warehouse[0].in_type_id.id
|
|
||||||
else:
|
|
||||||
picking = self._default_picking_type()
|
|
||||||
picking_type_id = picking.id
|
|
||||||
|
|
||||||
res.update({
|
|
||||||
'branch_id' : branch_id,
|
|
||||||
'picking_type_id' : picking_type_id
|
|
||||||
})
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string='Branch')
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _prepare_picking(self):
|
|
||||||
res = super(PurchaseOrder, self)._prepare_picking()
|
|
||||||
branch_id = False
|
|
||||||
if self.branch_id:
|
|
||||||
branch_id = self.branch_id.id
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
res.update({
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
def _prepare_invoice(self):
|
|
||||||
result = super(PurchaseOrder, self)._prepare_invoice()
|
|
||||||
branch_id = False
|
|
||||||
if self.branch_id:
|
|
||||||
branch_id = self.branch_id.id
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
result.update({
|
|
||||||
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
|
|
||||||
return result
|
|
||||||
def action_view_invoice(self, invoices=False):
|
|
||||||
'''
|
|
||||||
This function returns an action that display existing vendor bills of given purchase order ids.
|
|
||||||
When only one found, show the vendor bill immediately.
|
|
||||||
'''
|
|
||||||
|
|
||||||
result = super(PurchaseOrder, self).action_view_invoice(invoices)
|
|
||||||
|
|
||||||
branch_id = False
|
|
||||||
if self.branch_id:
|
|
||||||
branch_id = self.branch_id.id
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
|
|
||||||
result.update({
|
|
||||||
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
|
|
||||||
|
|
||||||
class ResUsers(models.Model):
|
|
||||||
_inherit = 'res.users'
|
|
||||||
|
|
||||||
branch_ids = fields.Many2many('res.branch',string="Allowed Branch")
|
|
||||||
branch_id = fields.Many2one('res.branch', string= 'Branch')
|
|
||||||
|
|
||||||
def write(self, values):
|
|
||||||
if 'branch_id' in values or 'branch_ids' in values:
|
|
||||||
self.env['ir.model.access'].call_cache_clearing_methods()
|
|
||||||
self.env['ir.rule'].clear_caches()
|
|
||||||
# self.has_group.clear_cache(self)
|
|
||||||
user = super(ResUsers, self).write(values)
|
|
||||||
return user
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class SaleOrder(models.Model):
|
|
||||||
_inherit = 'sale.order'
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self,fields):
|
|
||||||
res = super(SaleOrder, self).default_get(fields)
|
|
||||||
branch_id = warehouse_id = False
|
|
||||||
if self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
if branch_id:
|
|
||||||
branched_warehouse = self.env['stock.warehouse'].search([('branch_id','=',branch_id)])
|
|
||||||
if branched_warehouse:
|
|
||||||
warehouse_id = branched_warehouse.ids[0]
|
|
||||||
else:
|
|
||||||
warehouse_id = self._default_warehouse_id()
|
|
||||||
warehouse_id = warehouse_id.id
|
|
||||||
|
|
||||||
res.update({
|
|
||||||
'branch_id' : branch_id,
|
|
||||||
'warehouse_id' : warehouse_id
|
|
||||||
})
|
|
||||||
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
|
||||||
|
|
||||||
|
|
||||||
def _prepare_invoice(self):
|
|
||||||
res = super(SaleOrder, self)._prepare_invoice()
|
|
||||||
res['branch_id'] = self.branch_id.id
|
|
||||||
return res
|
|
||||||
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class stock_inventory(models.Model):
|
|
||||||
_inherit = 'stock.inventory'
|
|
||||||
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self,fields):
|
|
||||||
res = super(stock_inventory, self).default_get(fields)
|
|
||||||
if res.get('location_id'):
|
|
||||||
location_branch = self.env['stock.location'].browse(res.get('location_id')).branch_id.id
|
|
||||||
if location_branch:
|
|
||||||
res['branch_id'] = location_branch
|
|
||||||
else:
|
|
||||||
user_branch = self.env.user.branch_id
|
|
||||||
if user_branch:
|
|
||||||
res['branch_id'] = user_branch.id
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
|
|
||||||
def post_inventory(self):
|
|
||||||
# The inventory is posted as a single step which means quants cannot be moved from an internal location to another using an inventory
|
|
||||||
# as they will be moved to inventory loss, and other quants will be created to the encoded quant location. This is a normal behavior
|
|
||||||
# as quants cannot be reuse from inventory location (users can still manually move the products before/after the inventory if they want).
|
|
||||||
self.mapped('move_ids').filtered(lambda move: move.state != 'done')._action_done()
|
|
||||||
for move_id in self.move_ids:
|
|
||||||
account_move =self.env['account.move'].search([('stock_move_id','=',move_id.id)])
|
|
||||||
account_move.write({'branch_id':self.branch_id.id})
|
|
||||||
for line in account_move.line_ids:
|
|
||||||
line.write({'branch_id':self.branch_id.id})
|
|
||||||
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class StockLocation(models.Model):
|
|
||||||
_inherit = 'stock.location'
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
@api.constrains('branch_id')
|
|
||||||
def _check_branch(self):
|
|
||||||
warehouse_obj = self.env['stock.warehouse']
|
|
||||||
warehouse_id = warehouse_obj.search(
|
|
||||||
['|', '|', ('wh_input_stock_loc_id', '=', self.id),
|
|
||||||
('lot_stock_id', '=', self.id),
|
|
||||||
('wh_output_stock_loc_id', '=', self.id)])
|
|
||||||
for warehouse in warehouse_id:
|
|
||||||
if self.branch_id != warehouse.branch_id:
|
|
||||||
raise UserError(_('Configuration error\nYou must select same branch on a location as assigned on a warehouse configuration.'))
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
from itertools import groupby
|
|
||||||
|
|
||||||
class StockMove(models.Model):
|
|
||||||
_inherit = 'stock.move'
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
def _assign_picking(self):
|
|
||||||
""" Try to assign the moves to an existing picking that has not been
|
|
||||||
reserved yet and has the same procurement group, locations and picking
|
|
||||||
type (moves should already have them identical). Otherwise, create a new
|
|
||||||
picking to assign them to. """
|
|
||||||
Picking = self.env['stock.picking']
|
|
||||||
grouped_moves = groupby(sorted(self, key=lambda m: [f.id for f in m._key_assign_picking()]), key=lambda m: [m._key_assign_picking()])
|
|
||||||
for group, moves in grouped_moves:
|
|
||||||
moves = self.env['stock.move'].concat(*list(moves))
|
|
||||||
branch_id = self.group_id.sale_id.branch_id.id if self.group_id.sale_id and self.group_id.sale_id.branch_id else False
|
|
||||||
moves.write({'branch_id': branch_id})
|
|
||||||
new_picking = False
|
|
||||||
# Could pass the arguments contained in group but they are the same
|
|
||||||
# for each move that why moves[0] is acceptable
|
|
||||||
picking = moves[0]._search_picking_for_assignation()
|
|
||||||
if picking:
|
|
||||||
if any(picking.partner_id.id != m.partner_id.id or
|
|
||||||
picking.origin != m.origin for m in moves):
|
|
||||||
# If a picking is found, we'll append `move` to its move list and thus its
|
|
||||||
# `partner_id` and `ref` field will refer to multiple records. In this
|
|
||||||
# case, we chose to wipe them.
|
|
||||||
picking.write({
|
|
||||||
'partner_id': False,
|
|
||||||
'origin': False,
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
new_picking = True
|
|
||||||
picking = Picking.create(moves._get_new_picking_values())
|
|
||||||
|
|
||||||
moves.write({'picking_id': picking.id})
|
|
||||||
moves._assign_picking_post_process(new=new_picking)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _get_new_picking_values(self):
|
|
||||||
vals = super(StockMove, self)._get_new_picking_values()
|
|
||||||
vals['branch_id'] = self.group_id.sale_id.branch_id.id
|
|
||||||
return vals
|
|
||||||
|
|
||||||
def _create_account_move_line(self, credit_account_id, debit_account_id, journal_id, qty, description, svl_id, cost):
|
|
||||||
self.ensure_one()
|
|
||||||
AccountMove = self.env['account.move'].with_context(default_journal_id=journal_id)
|
|
||||||
|
|
||||||
move_lines = self._prepare_account_move_line(qty, cost, credit_account_id, debit_account_id, description)
|
|
||||||
if move_lines:
|
|
||||||
date = self._context.get('force_period_date', fields.Date.context_today(self))
|
|
||||||
new_account_move = AccountMove.sudo().create({
|
|
||||||
'journal_id': journal_id,
|
|
||||||
'line_ids': move_lines,
|
|
||||||
'date': date,
|
|
||||||
'ref': description,
|
|
||||||
'stock_move_id': self.id,
|
|
||||||
'stock_valuation_layer_ids': [(6, None, [svl_id])],
|
|
||||||
'move_type': 'entry',
|
|
||||||
'branch_id': self.picking_id.branch_id.id or self.branch_id.id or False,
|
|
||||||
})
|
|
||||||
new_account_move._post()
|
|
||||||
|
|
||||||
def _generate_valuation_lines_data(self, partner_id, qty, debit_value, credit_value, debit_account_id, credit_account_id, description):
|
|
||||||
# This method returns a dictionary to provide an easy extension hook to modify the valuation lines (see purchase for an example)
|
|
||||||
result = super(StockMove, self)._generate_valuation_lines_data(partner_id, qty, debit_value, credit_value, debit_account_id, credit_account_id, description)
|
|
||||||
|
|
||||||
branch_id = False
|
|
||||||
if self.branch_id:
|
|
||||||
branch_id = self.branch_id.id
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
for res in result:
|
|
||||||
result[res].update({'branch_id' : branch_id})
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class StockPicking(models.Model):
|
|
||||||
_inherit = 'stock.picking'
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, default_fields):
|
|
||||||
res = super(StockPicking, self).default_get(default_fields)
|
|
||||||
if self.env.user.branch_id:
|
|
||||||
res.update({
|
|
||||||
'branch_id' : self.env.user.branch_id.id or False
|
|
||||||
})
|
|
||||||
return res
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch', string="Branch")
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
class StockWarehouse(models.Model):
|
|
||||||
_inherit = 'stock.warehouse'
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StockPickingTypeIn(models.Model):
|
|
||||||
_inherit = 'stock.picking.type'
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch',related='warehouse_id.branch_id', store=True,)
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from . import sale_report
|
|
||||||
from . import account_invoice_report
|
|
||||||
from . import purchase_report
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoiceReport(models.Model):
|
|
||||||
_inherit = "account.invoice.report"
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
def _select(self):
|
|
||||||
return super(AccountInvoiceReport, self)._select() + ", move.branch_id"
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class PurchaseReport(models.Model):
|
|
||||||
_inherit = "purchase.report"
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
def _select(self):
|
|
||||||
return super(PurchaseReport, self)._select() + ", po.branch_id as branch_id"
|
|
||||||
|
|
||||||
def _group_by(self):
|
|
||||||
return super(PurchaseReport, self)._group_by() + ", po.branch_id"
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import fields, models
|
|
||||||
|
|
||||||
|
|
||||||
class SaleReport(models.Model):
|
|
||||||
_inherit = "sale.report"
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
def _query(self, with_clause='', fields={}, groupby='', from_clause=''):
|
|
||||||
fields['branch_id'] = ", s.branch_id as branch_id"
|
|
||||||
return super(SaleReport, self)._query(with_clause, fields, groupby, from_clause)
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data noupdate="1">
|
|
||||||
<record id="group_multi_branch" model="res.groups">
|
|
||||||
<field name="name">Multi Branches</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<record id="view_bank_statement_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.bank.statement.form.inherit.branch</field>
|
|
||||||
<field name="model">account.bank.statement</field>
|
|
||||||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="date" position="before">
|
|
||||||
<!-- Add your fields or attributes here -->
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
|
|
||||||
<xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="after">
|
|
||||||
<field name='branch_id'/>
|
|
||||||
</xpath>
|
|
||||||
|
|
||||||
<xpath expr="//field[@name='line_ids']" position="attributes">
|
|
||||||
<attribute name="context">{'branch_id' : branch_id}</attribute>
|
|
||||||
</xpath>
|
|
||||||
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
|
|
||||||
<record id="account_move_branch_view_tree" model="ir.ui.view" >
|
|
||||||
<field name="name">account.move.inherit.tree</field>
|
|
||||||
<field name="model">account.move</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="account_move_branch_view_tree1" model="ir.ui.view" >
|
|
||||||
<field name="name">account.move.inherit.tree1</field>
|
|
||||||
<field name="model">account.move</field>
|
|
||||||
<field name="inherit_id" ref="account.view_invoice_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="account_payment_branch_view_tree" model="ir.ui.view" >
|
|
||||||
<field name="name">account.payment.inherit.tree</field>
|
|
||||||
<field name="model">account.payment</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_payment_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="account_move_line_branch_view_form" model="ir.ui.view" >
|
|
||||||
<field name="name">account.move.line.inherit.form</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_line_form" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="partner_id" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="account_move_line_branch_view_tree2" model="ir.ui.view" >
|
|
||||||
<field name="name">account.move.line.inherit.tree2</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_line_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- journal entry Inherit Form View to Modify it -->
|
|
||||||
<record id="view_move_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.move.form.inherit.branch</field>
|
|
||||||
<field name="model">account.move</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//div[@name='journal_div']" position="after">
|
|
||||||
<label for="branch_id"/>
|
|
||||||
<div name="branch_div" class="d-flex">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</div>
|
|
||||||
</xpath>
|
|
||||||
<!-- <xpath expr="//field[@name='line_ids']" position="attributes">
|
|
||||||
<attribute name="context">{'branch_id' : branch_id}</attribute>
|
|
||||||
</xpath>
|
|
||||||
<xpath expr="//field[@name='invoice_line_ids']" position="attributes">
|
|
||||||
<attribute name="context">{'branch_id' : branch_id}</attribute>
|
|
||||||
</xpath> -->
|
|
||||||
<xpath expr="//field[@name='line_ids']//tree//field[@name='partner_id']" position="after">
|
|
||||||
<field optional="hide" name="branch_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_move_line_tree_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.move.line.tree.inherit.branch</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_move_line_tree"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='partner_id']" position="after">
|
|
||||||
<field name="branch_id" readonly="parent_state == 'posted'"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_move_line_order_filter_inherit_branch11" model="ir.ui.view">
|
|
||||||
<field name="name">move.line.filter.inherit.branch</field>
|
|
||||||
<field name="model">account.move.line</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_move_line_filter"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//group" position="inside">
|
|
||||||
<filter string="Branch" name="branch" domain="[]" context="{'group_by':'branch_id'}"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<odoo>
|
|
||||||
<record id="view_partner_structured_form_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view_partner_structured_form</field>
|
|
||||||
<field name="model">res.partner</field>
|
|
||||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="vat" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="product_template_form_view_branch" model="ir.ui.view">
|
|
||||||
<field name="name">product_extended.product.form.branch</field>
|
|
||||||
<field name="model">product.template</field>
|
|
||||||
<field name="inherit_id" ref="product.product_template_only_form_view" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="product_product_view_form_branch" model="ir.ui.view">
|
|
||||||
<field name="name">product.product.view.form.branch</field>
|
|
||||||
<field name="model">product.product</field>
|
|
||||||
<field name="inherit_id" ref="product.product_normal_form_view"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<record id="purchase_order_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">purchase.order.form.inherit.branch</field>
|
|
||||||
<field name="model">purchase.order</field>
|
|
||||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="incoterm_id" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
<xpath expr="//field[@name='order_line']" position="attributes">
|
|
||||||
<attribute name="context">{'branch_id' : branch_id}</attribute>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_purchase_order_filter_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.purchase.order.filter.inherit.branch</field>
|
|
||||||
<field name="model">purchase.order</field>
|
|
||||||
<field name="inherit_id" ref="purchase.view_purchase_order_filter"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//group" position="inside">
|
|
||||||
<filter string="Branch" name="branch" domain="[]" context="{'group_by':'branch_id'}"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="purchase_order_branch_view_tree" model="ir.ui.view" >
|
|
||||||
<field name="name">purchase.order.inherit.tree</field>
|
|
||||||
<field name="model">purchase.order</field>
|
|
||||||
<field name="inherit_id" ref="purchase.purchase_order_view_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
|
|
||||||
<record id="purchase_order_branch_view_tree1" model="ir.ui.view" >
|
|
||||||
<field name="name">purchase.order.inherit.tree1</field>
|
|
||||||
<field name="model">purchase.order</field>
|
|
||||||
<field name="inherit_id" ref="purchase.purchase_order_kpis_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- Users Inherit Form View to Modify it -->
|
|
||||||
<record id="view_users_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.users.form.inherit.branch</field>
|
|
||||||
<field name="model">res.users</field>
|
|
||||||
<field name="inherit_id" ref="base.view_users_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//sheet/notebook/page[2]/group[1]" position="before">
|
|
||||||
<!-- Add your fields or attributes here -->
|
|
||||||
<group name="branch">
|
|
||||||
<field name="branch_ids" widget="many2many_tags"/>
|
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</group>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_user_preference_form_extended" model="ir.ui.view">
|
|
||||||
<field name="name">res.user.preference.form.extended</field>
|
|
||||||
<field name="model">res.users</field>
|
|
||||||
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='company_id']" position="after">
|
|
||||||
<field name="branch_id" options="{'no_create': True}" context="{'branch_id':branch_id}" groups="branch.group_branch_user_manager"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- Sale order Inherit Form View to Modify it -->
|
|
||||||
<record id="view_order_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.order.form.inherit.branch</field>
|
|
||||||
<field name="model">sale.order</field>
|
|
||||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//page[@name='other_information']" position="inside">
|
|
||||||
<!-- Add your fields or attributes here -->
|
|
||||||
<group string="Branch" name="branch">
|
|
||||||
<group>
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<!-- Sale order Inherit search View to Modify it -->
|
|
||||||
<record id="view_sales_order_filter_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.sales.order.filter.inherit.branch</field>
|
|
||||||
<field name="model">sale.order</field>
|
|
||||||
<field name="inherit_id" ref="sale.view_sales_order_filter"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//group" position="inside">
|
|
||||||
<filter string="Branch" name="branch" domain="[]" context="{'group_by':'branch_id'}"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="sale_order_branch_view_tree" model="ir.ui.view" >
|
|
||||||
<field name="name">sale.order.inherit.tree</field>
|
|
||||||
<field name="model">sale.order</field>
|
|
||||||
<field name="inherit_id" ref="sale.view_order_tree" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="sale_order_branch_view_tree1" model="ir.ui.view" >
|
|
||||||
<field name="name">sale.order.inherit.tree1</field>
|
|
||||||
<field name="model">sale.order</field>
|
|
||||||
<field name="inherit_id" ref="sale.view_quotation_tree_with_onboarding" />
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="company_id" position="after">
|
|
||||||
<field name="branch_id" optional="hide"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<record id="view_stock_inventory_adjustment_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.stock.inventory.adjustment.form.inherit.branch</field>
|
|
||||||
<field name="model">stock.inventory.adjustment.name</field>
|
|
||||||
<field name="inherit_id" ref="stock.stock_inventory_adjustment_name_form_view"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="inventory_adjustment_name" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<record id="view_location_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.location.form.inherit.branch</field>
|
|
||||||
<field name="model">stock.location</field>
|
|
||||||
<field name="inherit_id" ref="stock.view_location_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='company_id']" position="before">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- Stock move Inherit Form View to Modify it -->
|
|
||||||
<record id="view_move_form_inherit_branch_form_stock" model="ir.ui.view">
|
|
||||||
<field name="name">view.move.form.inherit.branch</field>
|
|
||||||
<field name="model">stock.move</field>
|
|
||||||
<field name="inherit_id" ref="stock.view_move_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='product_id']" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- Stock Picking Inherit Form View to Modify it -->
|
|
||||||
<record id="view_picking_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.picking.form.inherit.branch</field>
|
|
||||||
<field name="model">stock.picking</field>
|
|
||||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='origin']"
|
|
||||||
position="after">
|
|
||||||
<!-- Add your fields or attributes here -->
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<record id="view_warehouse_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.warehouse.inherit.branch</field>
|
|
||||||
<field name="model">stock.warehouse</field>
|
|
||||||
<field name="inherit_id" ref="stock.view_warehouse"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="code" position="after">
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_picking_type_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.stock.picking.type.inherit.branch</field>
|
|
||||||
<field name="model">stock.picking.type</field>
|
|
||||||
<field name="inherit_id" ref="stock.view_picking_type_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<field name="warehouse_id" position="after">
|
|
||||||
<field name="branch_id" invisible="1"/>
|
|
||||||
</field>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
<!-- <record id="view_account_payment_invoice_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.account.payment.invoice.form.inherit.branch</field>
|
|
||||||
<field name="model">account.payment</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_payment_register_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='communication']" position="after">
|
|
||||||
|
|
||||||
<field name="branch_id" invisible="1"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record> -->
|
|
||||||
|
|
||||||
<record id="view_account_payment_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.account.payment.invoice.form.inherit.branch</field>
|
|
||||||
<field name="model">account.payment</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_payment_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='company_id']" position="after">
|
|
||||||
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
|
|
||||||
<record id="view_account_payment_register_form_inherit_branch" model="ir.ui.view">
|
|
||||||
<field name="name">view.account.payment.register.form.inherit.branch</field>
|
|
||||||
<field name="model">account.payment.register</field>
|
|
||||||
<field name="inherit_id" ref="account.view_account_payment_register_form"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//field[@name='journal_id']" position="after">
|
|
||||||
|
|
||||||
<field name="branch_id"/>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
|
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
|
||||||
from odoo.exceptions import UserError
|
|
||||||
|
|
||||||
|
|
||||||
class SaleAdvancePaymentInv(models.TransientModel):
|
|
||||||
_inherit = 'sale.advance.payment.inv'
|
|
||||||
|
|
||||||
|
|
||||||
def _create_invoice(self, order, so_line, amount):
|
|
||||||
result = super(SaleAdvancePaymentInv, self)._create_invoice(order, so_line, amount)
|
|
||||||
|
|
||||||
branch_id = False
|
|
||||||
|
|
||||||
if order.branch_id:
|
|
||||||
branch_id = order.branch_id.id
|
|
||||||
elif self.env.user.branch_id:
|
|
||||||
branch_id = self.env.user.branch_id.id
|
|
||||||
|
|
||||||
result.write({
|
|
||||||
'branch_id' : branch_id
|
|
||||||
})
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
class AccountPaymentRegisterInv(models.TransientModel):
|
|
||||||
_inherit = 'account.payment.register'
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def default_get(self, fields):
|
|
||||||
rec = super(AccountPaymentRegisterInv, self).default_get(fields)
|
|
||||||
invoice_defaults = self.env['account.move'].browse(self._context.get('active_ids', []))
|
|
||||||
if invoice_defaults and len(invoice_defaults) == 1:
|
|
||||||
rec['branch_id'] = invoice_defaults.branch_id.id
|
|
||||||
return rec
|
|
||||||
|
|
||||||
branch_id = fields.Many2one('res.branch')
|
|
||||||
|
|
||||||
@api.onchange('branch_id')
|
|
||||||
def _onchange_branch_id(self):
|
|
||||||
selected_brach = self.branch_id
|
|
||||||
if selected_brach:
|
|
||||||
user_id = self.env.user
|
|
||||||
user_branch = user_id.sudo().branch_id
|
|
||||||
if user_branch and user_branch.id != selected_brach.id:
|
|
||||||
raise UserError("Please select active branch only. Other may create the Multi branch issue. \n\ne.g: If you wish to add other branch then Switch branch from the header and set that.")
|
|
||||||
Loading…
Reference in New Issue