[ADD]ADD new module account_attachments

This commit is contained in:
zainab8585 2024-09-10 09:23:16 +02:00
parent 5c90f96fbd
commit 87d1ae5e05
7 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1 @@
from . import models

View File

@ -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,
}

View File

@ -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 "قيد اليومية"

View File

@ -0,0 +1 @@
from . import account_move

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,23 @@
<!-- Inherit Form View to Modify it -->
<odoo>
<record id="account_move_view" model="ir.ui.view">
<field name="name">account.move.inherit.form.attachment</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='button_box']" position="inside">
<button name="get_attachments" type="object"
class="oe_stat_button"
icon="fa-file-text-o">
<field name="attach_no" widget="statinfo" string="Documents"/>
</button>
</xpath>
<xpath expr="//page[@name='other_info']" position="inside">
<group name="model_info" string='Model Info'>
<field readonly="1" name='res_model'/>
<field readonly="1" name='res_id'/>
</group>
</xpath>
</field>
</record>
</odoo>