From 875512ca6bfcf6f9df0885d2e9d96a4e982dcc75 Mon Sep 17 00:00:00 2001 From: Abdurrahman Saber Date: Wed, 17 Sep 2025 09:36:25 +0300 Subject: [PATCH] [REF] branch: remove old files, temp disable systray --- odex30_base/branch/__manifest__.py | 10 +- odex30_base/branch/hooks.py | 15 -- .../inherited_account_bank_statement.py | 64 -------- .../inherited_account_bank_statement_line.py | 25 ---- .../branch/models/inherited_account_move.py | 57 -------- .../models/inherited_account_payment.py | 34 ----- .../branch/models/inherited_customer.py | 19 --- .../branch/models/inherited_product.py | 19 --- .../branch/models/inherited_purchase_order.py | 137 ------------------ .../branch/models/inherited_res_users.py | 18 --- .../branch/models/inherited_sale_order.py | 48 ------ .../models/inherited_stock_inventory.py | 46 ------ .../branch/models/inherited_stock_location.py | 30 ---- .../branch/models/inherited_stock_move.py | 82 ----------- .../branch/models/inherited_stock_picking.py | 28 ---- .../models/inherited_stock_warehouse.py | 25 ---- odex30_base/branch/reports/__init__.py | 7 - .../inherited_account_invoice_report.py | 12 -- .../reports/inherited_purchase_report.py | 15 -- .../branch/reports/inherited_sale_report.py | 14 -- odex30_base/branch/security/multi_branch.xml | 8 - .../inherited_account_bank_statement.xml | 25 ---- .../views/inherited_account_invoice.xml | 107 -------------- .../branch/views/inherited_partner.xml | 13 -- .../branch/views/inherited_product.xml | 25 ---- .../branch/views/inherited_purchase_order.xml | 52 ------- .../branch/views/inherited_res_users.xml | 33 ----- .../branch/views/inherited_sale_order.xml | 55 ------- .../views/inherited_stock_inventory.xml | 15 -- .../branch/views/inherited_stock_location.xml | 15 -- .../branch/views/inherited_stock_move.xml | 16 -- .../branch/views/inherited_stock_picking.xml | 18 --- .../views/inherited_stock_warehouse.xml | 26 ---- .../wizard/inherited_account_payment.xml | 41 ------ .../inherited_sale_advance_payment_inv.py | 47 ------ 35 files changed, 5 insertions(+), 1196 deletions(-) delete mode 100644 odex30_base/branch/hooks.py delete mode 100644 odex30_base/branch/models/inherited_account_bank_statement.py delete mode 100644 odex30_base/branch/models/inherited_account_bank_statement_line.py delete mode 100644 odex30_base/branch/models/inherited_account_move.py delete mode 100644 odex30_base/branch/models/inherited_account_payment.py delete mode 100644 odex30_base/branch/models/inherited_customer.py delete mode 100644 odex30_base/branch/models/inherited_product.py delete mode 100644 odex30_base/branch/models/inherited_purchase_order.py delete mode 100644 odex30_base/branch/models/inherited_res_users.py delete mode 100644 odex30_base/branch/models/inherited_sale_order.py delete mode 100644 odex30_base/branch/models/inherited_stock_inventory.py delete mode 100644 odex30_base/branch/models/inherited_stock_location.py delete mode 100644 odex30_base/branch/models/inherited_stock_move.py delete mode 100644 odex30_base/branch/models/inherited_stock_picking.py delete mode 100644 odex30_base/branch/models/inherited_stock_warehouse.py delete mode 100644 odex30_base/branch/reports/__init__.py delete mode 100644 odex30_base/branch/reports/inherited_account_invoice_report.py delete mode 100644 odex30_base/branch/reports/inherited_purchase_report.py delete mode 100644 odex30_base/branch/reports/inherited_sale_report.py delete mode 100644 odex30_base/branch/security/multi_branch.xml delete mode 100644 odex30_base/branch/views/inherited_account_bank_statement.xml delete mode 100644 odex30_base/branch/views/inherited_account_invoice.xml delete mode 100644 odex30_base/branch/views/inherited_partner.xml delete mode 100644 odex30_base/branch/views/inherited_product.xml delete mode 100644 odex30_base/branch/views/inherited_purchase_order.xml delete mode 100644 odex30_base/branch/views/inherited_res_users.xml delete mode 100644 odex30_base/branch/views/inherited_sale_order.xml delete mode 100644 odex30_base/branch/views/inherited_stock_inventory.xml delete mode 100644 odex30_base/branch/views/inherited_stock_location.xml delete mode 100644 odex30_base/branch/views/inherited_stock_move.xml delete mode 100644 odex30_base/branch/views/inherited_stock_picking.xml delete mode 100644 odex30_base/branch/views/inherited_stock_warehouse.xml delete mode 100644 odex30_base/branch/wizard/inherited_account_payment.xml delete mode 100644 odex30_base/branch/wizard/inherited_sale_advance_payment_inv.py diff --git a/odex30_base/branch/__manifest__.py b/odex30_base/branch/__manifest__.py index e2de70f..ef7b256 100644 --- a/odex30_base/branch/__manifest__.py +++ b/odex30_base/branch/__manifest__.py @@ -39,11 +39,11 @@ 'views/stock_warehouse.xml', ], - 'assets': { - 'web.assets_backend': [ - 'branch/static/src/**/*', - ] - }, + # 'assets': { + # 'web.assets_backend': [ + # 'branch/static/src/**/*', + # ] + # }, 'installable': True, 'auto_install': False, 'live_test_url':'https://youtu.be/hi1b8kH5Z94', diff --git a/odex30_base/branch/hooks.py b/odex30_base/branch/hooks.py deleted file mode 100644 index d26afc8..0000000 --- a/odex30_base/branch/hooks.py +++ /dev/null @@ -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' """) diff --git a/odex30_base/branch/models/inherited_account_bank_statement.py b/odex30_base/branch/models/inherited_account_bank_statement.py deleted file mode 100644 index 952f92e..0000000 --- a/odex30_base/branch/models/inherited_account_bank_statement.py +++ /dev/null @@ -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")}) \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_account_bank_statement_line.py b/odex30_base/branch/models/inherited_account_bank_statement_line.py deleted file mode 100644 index cdda49b..0000000 --- a/odex30_base/branch/models/inherited_account_bank_statement_line.py +++ /dev/null @@ -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') - diff --git a/odex30_base/branch/models/inherited_account_move.py b/odex30_base/branch/models/inherited_account_move.py deleted file mode 100644 index ec6d468..0000000 --- a/odex30_base/branch/models/inherited_account_move.py +++ /dev/null @@ -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) diff --git a/odex30_base/branch/models/inherited_account_payment.py b/odex30_base/branch/models/inherited_account_payment.py deleted file mode 100644 index ae8da45..0000000 --- a/odex30_base/branch/models/inherited_account_payment.py +++ /dev/null @@ -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.") diff --git a/odex30_base/branch/models/inherited_customer.py b/odex30_base/branch/models/inherited_customer.py deleted file mode 100644 index 6c5ac64..0000000 --- a/odex30_base/branch/models/inherited_customer.py +++ /dev/null @@ -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") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_product.py b/odex30_base/branch/models/inherited_product.py deleted file mode 100644 index b1ffccd..0000000 --- a/odex30_base/branch/models/inherited_product.py +++ /dev/null @@ -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") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_purchase_order.py b/odex30_base/branch/models/inherited_purchase_order.py deleted file mode 100644 index f064b77..0000000 --- a/odex30_base/branch/models/inherited_purchase_order.py +++ /dev/null @@ -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.") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_res_users.py b/odex30_base/branch/models/inherited_res_users.py deleted file mode 100644 index d278b0d..0000000 --- a/odex30_base/branch/models/inherited_res_users.py +++ /dev/null @@ -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 diff --git a/odex30_base/branch/models/inherited_sale_order.py b/odex30_base/branch/models/inherited_sale_order.py deleted file mode 100644 index 93ddbc0..0000000 --- a/odex30_base/branch/models/inherited_sale_order.py +++ /dev/null @@ -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.") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_stock_inventory.py b/odex30_base/branch/models/inherited_stock_inventory.py deleted file mode 100644 index 4576f53..0000000 --- a/odex30_base/branch/models/inherited_stock_inventory.py +++ /dev/null @@ -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.") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_stock_location.py b/odex30_base/branch/models/inherited_stock_location.py deleted file mode 100644 index 5da195f..0000000 --- a/odex30_base/branch/models/inherited_stock_location.py +++ /dev/null @@ -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.") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_stock_move.py b/odex30_base/branch/models/inherited_stock_move.py deleted file mode 100644 index 606408b..0000000 --- a/odex30_base/branch/models/inherited_stock_move.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_stock_picking.py b/odex30_base/branch/models/inherited_stock_picking.py deleted file mode 100644 index 63dedaf..0000000 --- a/odex30_base/branch/models/inherited_stock_picking.py +++ /dev/null @@ -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.") \ No newline at end of file diff --git a/odex30_base/branch/models/inherited_stock_warehouse.py b/odex30_base/branch/models/inherited_stock_warehouse.py deleted file mode 100644 index 6c736de..0000000 --- a/odex30_base/branch/models/inherited_stock_warehouse.py +++ /dev/null @@ -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,) diff --git a/odex30_base/branch/reports/__init__.py b/odex30_base/branch/reports/__init__.py deleted file mode 100644 index c05f583..0000000 --- a/odex30_base/branch/reports/__init__.py +++ /dev/null @@ -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 - - diff --git a/odex30_base/branch/reports/inherited_account_invoice_report.py b/odex30_base/branch/reports/inherited_account_invoice_report.py deleted file mode 100644 index 63f29cf..0000000 --- a/odex30_base/branch/reports/inherited_account_invoice_report.py +++ /dev/null @@ -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" \ No newline at end of file diff --git a/odex30_base/branch/reports/inherited_purchase_report.py b/odex30_base/branch/reports/inherited_purchase_report.py deleted file mode 100644 index 32fde6b..0000000 --- a/odex30_base/branch/reports/inherited_purchase_report.py +++ /dev/null @@ -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" \ No newline at end of file diff --git a/odex30_base/branch/reports/inherited_sale_report.py b/odex30_base/branch/reports/inherited_sale_report.py deleted file mode 100644 index 2ec518c..0000000 --- a/odex30_base/branch/reports/inherited_sale_report.py +++ /dev/null @@ -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) - diff --git a/odex30_base/branch/security/multi_branch.xml b/odex30_base/branch/security/multi_branch.xml deleted file mode 100644 index 0041133..0000000 --- a/odex30_base/branch/security/multi_branch.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Multi Branches - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_account_bank_statement.xml b/odex30_base/branch/views/inherited_account_bank_statement.xml deleted file mode 100644 index 4bd5c38..0000000 --- a/odex30_base/branch/views/inherited_account_bank_statement.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - view.bank.statement.form.inherit.branch - account.bank.statement - - - - - - - - - - - - - {'branch_id' : branch_id} - - - - - - diff --git a/odex30_base/branch/views/inherited_account_invoice.xml b/odex30_base/branch/views/inherited_account_invoice.xml deleted file mode 100644 index 8610e1e..0000000 --- a/odex30_base/branch/views/inherited_account_invoice.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - account.move.inherit.tree - account.move - - - - - - - - - - account.move.inherit.tree1 - account.move - - - - - - - - - - account.payment.inherit.tree - account.payment - - - - - - - - - - account.move.line.inherit.form - account.move.line - - - - - - - - - - account.move.line.inherit.tree2 - account.move.line - - - - - - - - - - - view.move.form.inherit.branch - account.move - - - - - - - - - - - - - view.move.line.tree.inherit.branch - account.move.line - - - - - - - - - - move.line.filter.inherit.branch - account.move.line - - - - - - - - - - diff --git a/odex30_base/branch/views/inherited_partner.xml b/odex30_base/branch/views/inherited_partner.xml deleted file mode 100644 index 4e4eff0..0000000 --- a/odex30_base/branch/views/inherited_partner.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - view_partner_structured_form - res.partner - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_product.xml b/odex30_base/branch/views/inherited_product.xml deleted file mode 100644 index 8f42537..0000000 --- a/odex30_base/branch/views/inherited_product.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - product_extended.product.form.branch - product.template - - - - - - - - - - product.product.view.form.branch - product.product - - - - - - - - - diff --git a/odex30_base/branch/views/inherited_purchase_order.xml b/odex30_base/branch/views/inherited_purchase_order.xml deleted file mode 100644 index d7b1ce9..0000000 --- a/odex30_base/branch/views/inherited_purchase_order.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - purchase.order.form.inherit.branch - purchase.order - - - - - - - {'branch_id' : branch_id} - - - - - - view.purchase.order.filter.inherit.branch - purchase.order - - - - - - - - - - purchase.order.inherit.tree - purchase.order - - - - - - - - - - - purchase.order.inherit.tree1 - purchase.order - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_res_users.xml b/odex30_base/branch/views/inherited_res_users.xml deleted file mode 100644 index d63a310..0000000 --- a/odex30_base/branch/views/inherited_res_users.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - view.users.form.inherit.branch - res.users - - - - - - - - - - - - - - - - res.user.preference.form.extended - res.users - - - - - - - - - diff --git a/odex30_base/branch/views/inherited_sale_order.xml b/odex30_base/branch/views/inherited_sale_order.xml deleted file mode 100644 index 56fe6d1..0000000 --- a/odex30_base/branch/views/inherited_sale_order.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - view.order.form.inherit.branch - sale.order - - - - - - - - - - - - - - - - view.sales.order.filter.inherit.branch - sale.order - - - - - - - - - - sale.order.inherit.tree - sale.order - - - - - - - - - - sale.order.inherit.tree1 - sale.order - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_stock_inventory.xml b/odex30_base/branch/views/inherited_stock_inventory.xml deleted file mode 100644 index 7af7e10..0000000 --- a/odex30_base/branch/views/inherited_stock_inventory.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - view.stock.inventory.adjustment.form.inherit.branch - stock.inventory.adjustment.name - - - - - - - - - diff --git a/odex30_base/branch/views/inherited_stock_location.xml b/odex30_base/branch/views/inherited_stock_location.xml deleted file mode 100644 index 2d9df9b..0000000 --- a/odex30_base/branch/views/inherited_stock_location.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - view.location.form.inherit.branch - stock.location - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_stock_move.xml b/odex30_base/branch/views/inherited_stock_move.xml deleted file mode 100644 index e7038e7..0000000 --- a/odex30_base/branch/views/inherited_stock_move.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - view.move.form.inherit.branch - stock.move - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_stock_picking.xml b/odex30_base/branch/views/inherited_stock_picking.xml deleted file mode 100644 index 1a69385..0000000 --- a/odex30_base/branch/views/inherited_stock_picking.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - view.picking.form.inherit.branch - stock.picking - - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/views/inherited_stock_warehouse.xml b/odex30_base/branch/views/inherited_stock_warehouse.xml deleted file mode 100644 index 6bb83d3..0000000 --- a/odex30_base/branch/views/inherited_stock_warehouse.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - view.warehouse.inherit.branch - stock.warehouse - - - - - - - - - - view.stock.picking.type.inherit.branch - stock.picking.type - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/wizard/inherited_account_payment.xml b/odex30_base/branch/wizard/inherited_account_payment.xml deleted file mode 100644 index bbea15b..0000000 --- a/odex30_base/branch/wizard/inherited_account_payment.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - view.account.payment.invoice.form.inherit.branch - account.payment - - - - - - - - - - - - view.account.payment.register.form.inherit.branch - account.payment.register - - - - - - - - - - \ No newline at end of file diff --git a/odex30_base/branch/wizard/inherited_sale_advance_payment_inv.py b/odex30_base/branch/wizard/inherited_sale_advance_payment_inv.py deleted file mode 100644 index 2ddd9e0..0000000 --- a/odex30_base/branch/wizard/inherited_sale_advance_payment_inv.py +++ /dev/null @@ -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.") \ No newline at end of file