| @ -0,0 +1,53 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ############################################################################# | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | |||
| #    Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) | |||
| # | |||
| #    You can modify it under the terms of the GNU LESSER | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | |||
| # | |||
| #    This program is distributed in the hope that it will be useful, | |||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
| #    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |||
| # | |||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |||
| #    (LGPL v3) along with this program. | |||
| #    If not, see <http://www.gnu.org/licenses/>. | |||
| # | |||
| ############################################################################# | |||
| from odoo import api, fields, models, _ | |||
| from odoo.exceptions import ValidationError | |||
| 
 | |||
| 
 | |||
| class AccountMove(models.Model): | |||
|     """Inherited model for checking the journal type in account.move.""" | |||
|     _inherit = 'account.move' | |||
| 
 | |||
|     check_journal = fields.Boolean(string="Check Journal", | |||
|                                    help="Compute field for check the current " | |||
|                                         "record's journal type ", | |||
|                                    compute="_compute_journal") | |||
| 
 | |||
|     def _compute_journal(self): | |||
|         """Compute field for showing validation error for restricted journal's | |||
|         records""" | |||
|         self.check_journal = True | |||
|         for rec in self.line_ids: | |||
|             if rec.full_reconcile_id: | |||
|                 payment = self.env['account.payment.register'].search( | |||
|                     [('id', '=', rec.full_reconcile_id.id)]) | |||
|                 if payment.journal_id.id in self.env.user.journal_ids.ids: | |||
|                     raise ValidationError(_('Restricted journals found.')) | |||
|         if self.journal_id.id in self.env.user.journal_ids.ids: | |||
|             raise ValidationError(_('Restricted journals found.')) | |||
| 
 | |||
|     @api.onchange('partner_id') | |||
|     def _onchange_partner_id(self): | |||
|         """Function for hiding restricted journals from account.move.""" | |||
|         if self.journal_id.id in self.env.user.journal_ids.ids: | |||
|             self.journal_id = False | |||
|         return super(AccountMove, self)._onchange_partner_id() | |||
| @ -0,0 +1,62 @@ | |||
| # -*- coding: utf-8 -*- | |||
| ############################################################################# | |||
| # | |||
| #    Cybrosys Technologies Pvt. Ltd. | |||
| # | |||
| #    Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) | |||
| #    Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) | |||
| # | |||
| #    You can modify it under the terms of the GNU LESSER | |||
| #    GENERAL PUBLIC LICENSE (LGPL v3), Version 3. | |||
| # | |||
| #    This program is distributed in the hope that it will be useful, | |||
| #    but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | |||
| #    GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. | |||
| # | |||
| #    You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE | |||
| #    (LGPL v3) along with this program. | |||
| #    If not, see <http://www.gnu.org/licenses/>. | |||
| # | |||
| ############################################################################# | |||
| from odoo import api, models | |||
| 
 | |||
| 
 | |||
| class AccountPaymentRegister(models.TransientModel): | |||
|     """ Adding allowed journal in functionality""" | |||
| 
 | |||
|     _inherit = 'account.payment.register' | |||
| 
 | |||
|     @api.depends('payment_type', 'company_id', 'can_edit_wizard') | |||
|     def _compute_available_journal_ids(self): | |||
|         """ | |||
|         Check all available journals on register payment. | |||
|         """ | |||
|         for wizard in self: | |||
|             if wizard.can_edit_wizard: | |||
|                 batch = wizard._get_batches()[0] | |||
|                 wizard.available_journal_ids = wizard._get_batch_available_journals( | |||
|                     batch) | |||
|             else: | |||
|                 wizard.available_journal_ids = self.env[ | |||
|                     'account.journal'].search( | |||
|                     [('company_id', '=', wizard.company_id.id), | |||
|                      ('type', 'in', ('bank', 'cash')), | |||
|                      ('id', 'not in', self.env.user.journal_ids.ids)]) | |||
| 
 | |||
|     @api.model | |||
|     def _get_batch_available_journals(self, batch_result): | |||
|         """ Helper to compute the available journals based on the batch. | |||
| 
 | |||
|         :param batch_result:    A batch returned by '_get_batches'. | |||
|         :return:                A recordset of account.journal. | |||
|         """ | |||
|         payment_type = batch_result['payment_values']['payment_type'] | |||
|         company = batch_result['lines'].company_id | |||
|         journals = self.env['account.journal'].search( | |||
|             [('company_id', '=', company.id), ('type', 'in', ('bank', 'cash')), | |||
|              ('id', 'not in', self.env.user.journal_ids.ids)]) | |||
|         if payment_type == 'inbound': | |||
|             return journals.filtered('inbound_payment_method_line_ids') | |||
|         else: | |||
|             return journals.filtered('outbound_payment_method_line_ids') | |||
| @ -1,7 +1,8 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
| <!--    New user group created for journal restriction--> | |||
|     <record id="user_allowed_journal" model="res.groups"> | |||
|         <field name="name">Restrict Journals</field> | |||
|         <field name="category_id" ref="base.module_category_usability"/> | |||
|     </record> | |||
| </odoo> | |||
| </odoo> | |||
|  | |||
| Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 86 KiB | 
| Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 79 KiB | 
| Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 87 KiB | 
| Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 80 KiB | 
| After Width: | Height: | Size: 110 KiB | 
| After Width: | Height: | Size: 87 KiB | 
| After Width: | Height: | Size: 100 KiB | 
| After Width: | Height: | Size: 68 KiB | 
| After Width: | Height: | Size: 86 KiB | 
| After Width: | Height: | Size: 61 KiB | 
| After Width: | Height: | Size: 112 KiB | 
| After Width: | Height: | Size: 122 KiB | 
| After Width: | Height: | Size: 138 KiB | 
| After Width: | Height: | Size: 119 KiB | 
| After Width: | Height: | Size: 117 KiB | 
| After Width: | Height: | Size: 93 KiB | 
| Before Width: | Height: | Size: 152 KiB | 
| Before Width: | Height: | Size: 133 KiB | 
| Before Width: | Height: | Size: 86 KiB | 
| Before Width: | Height: | Size: 174 KiB | 
| Before Width: | Height: | Size: 112 KiB | 
| Before Width: | Height: | Size: 142 KiB | 
| Before Width: | Height: | Size: 107 KiB | 
| Before Width: | Height: | Size: 236 KiB | 
| After Width: | Height: | Size: 250 KiB | 
| After Width: | Height: | Size: 94 KiB | 
| After Width: | Height: | Size: 87 KiB | 
| @ -0,0 +1,16 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
|     <!-- Added fields for check journal type --> | |||
|     <record id="view_move_form" model="ir.ui.view"> | |||
|         <field name="name">account.move.form.inherit.account.restrict.journal | |||
|         </field> | |||
|         <field name="model">account.move</field> | |||
|         <field name="mode">extension</field> | |||
|         <field name="inherit_id" ref="account.view_move_form"/> | |||
|         <field name="arch" type="xml"> | |||
|             <xpath expr="//field[@name='currency_id']" position="after"> | |||
|                 <field name="check_journal" invisible="1"/> | |||
|             </xpath> | |||
|         </field> | |||
|     </record> | |||
| </odoo> | |||