Skip to content
Snippets Groups Projects
Commit 510293139b67 authored by oury.balde's avatar oury.balde
Browse files

[MIG] Port document attachment to odoo 13.0

parent 22e8d2670b9d
No related branches found
Tags 13.0.1.0.1
No related merge requests found
Pipeline #4531 passed
stages:
- test
- prepare
- main
black:
stage: test
image:
name: houzefaabba/python3-black
entrypoint: [/bin/busybox]
script:
- black --check -l79 .
flake8:
stage: test
image:
name: xcgd/flake8:3
entrypoint: [/bin/busybox]
script:
- flake8
isort:
stage: test
image: xcgd/isort:odoo
script:
- isort --check-only --diff
get_odoo_scripts:
stage: prepare
image:
name: xcgd/confman:evolve
artifacts:
paths:
- odoo_scripts
expire_in: 1h
script:
- hg clone https://orus.io/xcg/odoo_scripts
# change to coverage topic to test
- cd odoo_scripts
- hg update coverage-in-tests
test:
stage: main
image:
name: registry.xcg.io/odoo/odoo:11.0-bionic
entrypoint: [""]
services:
- name: postgres:11-alpine
cache:
paths:
- .cache
variables:
POSTGRES_DB: test
POSTGRES_USER: odoo
POSTGRES_PASSWORD: odoo
POSTGRES_HOST_AUTH_METHOD: trust
DEBIAN_FRONTEND: noninteractive
before_script:
- mkdir -p $CI_PROJECT_DIR/.cache/apt/archives/partial
# Fetch odoo_scripts dependencies for do_tests
- apt-get -q -o dir::cache::archives="$CI_PROJECT_DIR/.cache/apt" update
- apt-get -q -y -o dir::cache::archives="$CI_PROJECT_DIR/.cache/apt" install zsh
script:
# Run tests
- ./odoo_scripts/do_tests postgres odoo
- python3-coverage report -m
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
include:
- project: xcg/ci-templates
file: /odoo/13.0/gitlab-ci.yaml
......@@ -19,7 +19,7 @@
##############################################################################
{
"name": "Document Attachment",
"version": "11.0.1.0",
"version": "13.0.1.0.0",
"author": "XCG Consulting",
"category": "Hidden/Dependency",
"website": "http://odoo.consulting/",
......@@ -23,7 +23,7 @@
"author": "XCG Consulting",
"category": "Hidden/Dependency",
"website": "http://odoo.consulting/",
"depends": ["base", "document", "mail"],
"depends": ["base", "mail"],
"data": [
"security/ir.model.access.csv",
"views/document_attachment.xml",
......
This diff is collapsed.
......@@ -8,4 +8,6 @@
_name = "document_attachment"
_description = "Document Attachment"
type_id = fields.Many2one(
......@@ -11,5 +13,7 @@
type_id = fields.Many2one(
comodel_name="document_attachment.type", string="Type", required=True
comodel_name="document_attachment.type",
string="Attachment Type",
required=True,
)
file_id = fields.Many2one(
......@@ -20,10 +24,12 @@
delegate=True,
)
@api.model
def create(self, vals):
datas_fname = fields.Char("File Name")
@api.model_create_multi
def create(self, vals_list):
"""- Fill the "name" from the original filename.
- Associate the new attachment with the current object.
"""
# When wrapping an existing attachment, no need to pre-fill data.
......@@ -25,10 +31,11 @@
"""- Fill the "name" from the original filename.
- Associate the new attachment with the current object.
"""
# When wrapping an existing attachment, no need to pre-fill data.
if vals.get("file_id"):
return super(DocumentAttachment, self).create(vals)
for values in vals_list:
if values.get("file_id"):
return super().create(vals_list)
context = self._context
......@@ -42,5 +49,10 @@
_("You must send the 'res_id' through the m2m context")
)
vals["name"] = vals["datas_fname"]
for values in vals_list:
values.update(
name=values["datas_fname"],
res_model=context["res_model"],
res_id=context["res_id"],
)
......@@ -46,4 +58,3 @@
vals["res_model"] = context["res_model"]
vals["res_id"] = context["res_id"]
return super().create(vals_list)
......@@ -49,7 +60,4 @@
return super(DocumentAttachment, self).create(vals)
@api.multi
def write(self, vals):
"""Fill the "name" from the original filename."""
......@@ -58,7 +66,6 @@
return super(DocumentAttachment, self).write(vals)
@api.multi
def unlink(self):
"""Delete the attachment associated with records being deleted."""
......@@ -71,7 +78,6 @@
return ret
@api.multi
def get_metadata(self):
"""Helper function returning the document attachment metadata
Can be overridden to add some specifics metadata
......
......@@ -25,6 +25,8 @@
_name = "document_attachment.type"
_description = "Document Attachment Type"
name = fields.Char(string="Description", size=256, required=True)
model = fields.Char(string="Model", size=128, required=True)
......@@ -25,6 +25,8 @@
_name = "document_attachment.type_list"
_description = "Document Attachment Type List"
name = fields.Char(string="Description", required=True)
document_attachment_ids = fields.Many2many(
"document_attachment.type", string="Attachments type"
......
......@@ -18,7 +18,7 @@
#
##############################################################################
from odoo import api, fields, models
from odoo import fields, models
class IrActReport(models.Model):
......@@ -45,7 +45,6 @@
help="Specify the document attachment type",
)
@api.multi
def postprocess_pdf_report(self, record, buffer):
"""Catch invoice reports to save a typed link to the attached document.
"""
......
......@@ -20,7 +20,6 @@
import base64
from odoo import _, api, exceptions, fields, models
from odoo.tools import pycompat
class MailTemplate(models.Model):
......@@ -78,10 +77,9 @@
return values
@api.multi
def generate_email(self, res_ids, fields=None):
results = super(MailTemplate, self).generate_email(
res_ids, fields=fields
)
multi_mode = True
......@@ -82,10 +80,10 @@
def generate_email(self, res_ids, fields=None):
results = super(MailTemplate, self).generate_email(
res_ids, fields=fields
)
multi_mode = True
if isinstance(res_ids, pycompat.integer_types):
if isinstance(res_ids, int):
res_ids = [res_ids]
multi_mode = False
......@@ -105,6 +103,8 @@
class MailTemplateDocToAttach(models.Model):
_name = "mail.template.doc_to_attach"
_description = "Mail Template Document to Attach"
template_id = fields.Many2one(
comodel_name="mail.template", string="Email Template"
)
......
......@@ -29,4 +29,7 @@
<field name="arch" type="xml">
<form string="Documents">
<sheet>
<!-- Utility fields. -->
<field name="id" invisible="1" />
......@@ -32,6 +35,3 @@
<!-- Utility fields. -->
<field name="id" invisible="1" />
<group cols="2">
<group cols="2">
......@@ -37,5 +37,5 @@
<field name="type_id"
domain="[('model', '=', context.get('res_model'))]"
context="{'default_model': context.get('res_model')}" />
<field name="type_id"
domain="[('model', '=', context.get('res_model'))]"
context="{'default_model': context.get('res_model')}" />
......@@ -41,3 +41,3 @@
<!-- Inherited from ir.attachment. -->
<!-- Inherited from ir.attachment. -->
......@@ -43,5 +43,4 @@
<field name="datas" filename="datas_fname" />
<field name="datas_fname" invisible="1"
class="oe_inline oe_right" />
<field name="datas" filename="datas_fname" />
<!-- End -->
......@@ -47,3 +46,6 @@
</group>
<field name="datas_fname" invisible="1"
class="oe_inline oe_right" />
</group>
......@@ -49,11 +51,11 @@
<group col="4" attrs="{'invisible': [('id', '=', False)]}">
<field name="create_date" readonly="1" />
<field name="create_uid" readonly="1" />
<field name="write_date" readonly="1" />
<field name="write_uid" readonly="1" />
</group>
<group col="4" attrs="{'invisible': [('id', '=', False)]}">
<field name="create_date" readonly="1" />
<field name="create_uid" readonly="1" />
<field name="write_date" readonly="1" />
<field name="write_uid" readonly="1" />
</group>
</sheet>
</form>
</field>
......
......@@ -33,8 +33,7 @@
<record id="document_attachment_type_action" model="ir.actions.act_window">
<field name="name">Document Attachment Type</field>
<field name="res_model">document_attachment.type</field>
<field name="view_type">tree</field>
<field name="view_mode">list,form</field>
<field name="view_mode">tree,form</field>
</record>
<!--Setting > Document Attachment > Attachment Type -->
......
......@@ -37,8 +37,7 @@
<record id="document_attachment_type_list_action" model="ir.actions.act_window">
<field name="name">Document Attachment Type List</field>
<field name="res_model">document_attachment.type_list</field>
<field name="view_type">tree</field>
<field name="view_mode">list,form</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="email_template_form" model="ir.ui.view">
<field name="name">email.template.form</field>
<field name="model">mail.template</field>
<field name="inherit_id" ref="mail.email_template_form"/>
<field name="arch" type="xml">
<field name="report_name" position="after">
<field name="doc_to_attach_ids">
<tree editable="bottom">
<field name="field_id" domain="[('relation', '=', 'document_attachment')]"
options="{'no_create': True}"/>
<field name="report_template_id"/>
<field name="report_name"/>
</tree>
</field>
<record id="email_template_form" model="ir.ui.view">
<field name="name">email.template.form</field>
<field name="model">mail.template</field>
<field name="inherit_id" ref="mail.email_template_form"/>
<field name="arch" type="xml">
<field name="report_name" position="after">
<field name="doc_to_attach_ids">
<tree editable="bottom">
<field name="field_id" domain="[('relation', '=', 'document_attachment')]"
options="{'no_create': True}"/>
<field name="report_template_id"/>
<field name="report_name"/>
</tree>
</field>
......@@ -18,2 +20,3 @@
</field>
</field>
......@@ -19,4 +22,5 @@
</field>
</record>
</data>
</field>
</record>
</odoo>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment