diff --git a/odex25_accounting/account_attachments/__init__.py b/odex25_accounting/account_attachments/__init__.py new file mode 100755 index 000000000..0650744f6 --- /dev/null +++ b/odex25_accounting/account_attachments/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/odex25_accounting/account_attachments/__manifest__.py b/odex25_accounting/account_attachments/__manifest__.py new file mode 100755 index 000000000..0cc807a9e --- /dev/null +++ b/odex25_accounting/account_attachments/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +################################################################################ +{ + 'name': "Account Attachments", + 'version': '14.0.1.0.0', + 'category': 'Account', + 'summary': 'Helps to view all documents attached to account', + 'description': """account Attachments module allows user to view + all the documents attached to account.""", + 'company': 'Expert', + 'website': 'https://www.expert.com', + 'depends': ['base','account'], + 'data': [ + 'views/account_move_view.xml' + ], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': True, +} diff --git a/odex25_accounting/account_attachments/i18n/ar_001.po b/odex25_accounting/account_attachments/i18n/ar_001.po new file mode 100755 index 000000000..e4e85343b --- /dev/null +++ b/odex25_accounting/account_attachments/i18n/ar_001.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_attachments +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-09-09 07:49+0000\n" +"PO-Revision-Date: 2024-09-09 07:49+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_attachments +#: model:ir.model.fields,field_description:account_attachments.field_account_bank_statement_line__attach_no +#: model:ir.model.fields,field_description:account_attachments.field_account_move__attach_no +#: model:ir.model.fields,field_description:account_attachments.field_account_payment__attach_no +msgid "Attach No" +msgstr "مرفق" + +#. module: account_attachments +#: model_terms:ir.ui.view,arch_db:account_attachments.account_move_view +msgid "Documents" +msgstr "المرفقات" + +#. module: account_attachments +#: model:ir.model,name:account_attachments.model_account_move +msgid "Journal Entry" +msgstr "قيد اليومية" diff --git a/odex25_accounting/account_attachments/models/__init__.py b/odex25_accounting/account_attachments/models/__init__.py new file mode 100755 index 000000000..9c0a42138 --- /dev/null +++ b/odex25_accounting/account_attachments/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/odex25_accounting/account_attachments/models/account_move.py b/odex25_accounting/account_attachments/models/account_move.py new file mode 100755 index 000000000..185a95bd3 --- /dev/null +++ b/odex25_accounting/account_attachments/models/account_move.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from odoo import api, fields, models + +class AccountMove(models.Model): + + _inherit = 'account.move' + + attach_no = fields.Integer(compute='get_attachments') + res_id = fields.Integer() + res_model = fields.Char() + + def get_attachments(self): + self.ensure_one() + + action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment') + action['domain'] = [ + ('res_model', '=', 'account.move'), + ('res_id', 'in',self.ids), ] + domain = [ + ('res_model', '=', 'account.move'), + ('res_id', 'in', self.ids), ] + related_ids = self.ids + related_models = 'account.move' + + if self.res_id and self.res_model: + related_ids = self.ids + [self.res_id] + related_models = ['account.move', self.res_model] + action['domain'] = [ + ('res_model', 'in', related_models), + ('res_id', 'in', related_ids), ] + domain = [ + ('res_model', 'in', related_models), + ('res_id', 'in', related_ids), ] + + # Context for creating new attachments + action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id) + # Update attachment count for smart button + + + self.attach_no = self.env['ir.attachment'].search_count(domain) + + return action + + # def get_attachments(self): + # action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment') + # action['domain'] = str([('res_model', '=', 'account.move'), ('res_id', 'in', self.ids)]) + # action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id) + # domain = [('res_model', '=', 'account.move'), ('res_id', '=', self.id)] + # self.attach_no = self.env['ir.attachment'].search_count(domain) + # return action diff --git a/odex25_accounting/account_attachments/static/description/icon.png b/odex25_accounting/account_attachments/static/description/icon.png new file mode 100644 index 000000000..4141f52da Binary files /dev/null and b/odex25_accounting/account_attachments/static/description/icon.png differ diff --git a/odex25_accounting/account_attachments/views/account_move_view.xml b/odex25_accounting/account_attachments/views/account_move_view.xml new file mode 100755 index 000000000..ecdb45c71 --- /dev/null +++ b/odex25_accounting/account_attachments/views/account_move_view.xml @@ -0,0 +1,23 @@ + + + + account.move.inherit.form.attachment + account.move + + + + + + + + + + + + + +