# -*- coding: utf-8 -*-
###############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from odoo import api, fields, models
class IrAttachment(models.Model):
"""Inherit IR attachment for adding extra fields and inheriting create
function """
_inherit = 'ir.attachment'
attach_to = fields.Selection([('project', 'Project'),
('task', 'Task')],
required=True, string="Attach To",
help="if Project, file attached to Project."
" Otherwise to task.", default='project')
project_id = fields.Many2one('project.project',
string='Project',
help="This indicates the Project",
readonly="True")
task_id = fields.Many2one('project.task',
string='Task', help="This indicates the Task",
readonly="True")
@api.model_create_multi
def create(self, vals_list):
"""Supering the create function inorder to add the project and task
corresponding to the attachment"""
for vals in vals_list:
if 'project_id' in vals.keys() and not vals['task_id']:
vals['res_id'] = vals['project_id']
vals['res_model'] = 'project.project'
elif 'project_id' in vals.keys() and vals['task_id']:
vals['res_id'] = vals['task_id']
vals['res_model'] = 'project.task'
elif ('project_id' not in vals.keys() and vals['res_model'] ==
'project.project'):
vals['project_id'] = vals['res_id']
vals['attach_to'] = 'project'
elif 'task_id' not in vals.keys() and vals[
'res_model'] == 'project.task':
vals['task_id'] = vals['res_id']
vals['attach_to'] = 'task'
return super().create(vals_list)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
project_task_attachments-18.0.1.0.0.zip (91个子文件)
project_task_attachments
__init__.py 938B
doc
RELEASE_NOTES.md 136B
README.rst 1KB
__manifest__.py 2KB
models
__init__.py 945B
ir_attachment.py 3KB
static
description
assets
cybro-odoo.png 28KB
screenshots
3.png 50KB
1.png 113KB
6.png 42KB
5.png 43KB
4.png 150KB
2.png 165KB
y18.jpg 880KB
cybro-icon.png 2KB
h2.png 628KB
modules
3.png 46KB
6.jpg 85KB
2.gif 1.28MB
5.png 46KB
4.png 44KB
1.gif 912KB
icons
skype.svg 2KB
consultation.png 1KB
ecom-black.png 576B
notification icon.svg 462B
check.png 4KB
replace-icon.svg 800B
support.png 4KB
pattern1.png 7KB
feature.png 4KB
hire-odoo.svg 2KB
banner-pattern.svg 135KB
education-black.png 733B
hotel-black.png 911B
lifebuoy.png 1KB
brand-pair.svg 36KB
license.png 1KB
whatsapp.png 5KB
star-1.svg 34KB
mail.svg 600B
training.png 627B
translate.svg 1KB
puzzle.png 653B
notes.png 2KB
screenshot-main.png 189KB
banner-2.svg 209KB
star-2.svg 26KB
skype.png 6KB
pos-black.png 878B
screenshot.png 4KB
skype-fill.svg 2KB
test-2.png 2KB
manufacturing-black.png 673B
odoo-licencing.svg 926B
hero.gif 121KB
faq.png 4KB
service-black.png 839B
collabarate-icon.svg 3KB
chevron.png 310B
odoo-logo.png 9KB
user.png 988B
wrench-icon.svg 875B
puzzle-piece-icon.svg 1KB
cogs.png 1KB
banner-call.svg 1KB
restaurant-black.png 905B
banner-1.png 210KB
cybro-logo.png 17KB
wrench.png 1KB
close-icon.svg 929B
life-ring-icon.svg 1KB
video.png 4KB
patter.svg 23KB
banner-mail.svg 624B
update.png 1KB
test-1 - Copy.png 23KB
test-1.png 2KB
feature-icon.svg 1KB
banner-bg.png 109KB
down.svg 542B
banner-bg.svg 495B
trading-black.png 427B
gear.svg 2KB
arrows-repeat.svg 1KB
banner-promo.svg 214KB
odoo-consultancy.svg 2KB
banner.gif 90KB
index.html 70KB
icon.png 9KB
views
ir_attachment_views.xml 8KB
共 91 条
- 1
资源评论
weixin_42191514
- 粉丝: 0
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功