Change CI to GitHub actions

Use copier template from oca/oca-addons-repo-template

Target Python3.8

Apply linting

Fix a missing call to super
Ensure all modules have a 13.0.x.x.x version
This commit is contained in:
Yannick Payot
2023-05-11 11:17:54 +02:00
parent 0000eab313
commit 71da584087
80 changed files with 1596 additions and 879 deletions
-1
View File
@@ -1,2 +1 @@
from . import fields
+4 -5
View File
@@ -5,11 +5,10 @@
"summary": "Implementation of FileURL type fields",
"version": "13.0.1.0.0",
"category": "Technical Settings",
'author': 'Camptocamp, Odoo Community Association (OCA)',
'license': 'AGPL-3',
"depends": [
"base_attachment_object_storage",
],
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/camptocamp/odoo-cloud-platform",
"license": "AGPL-3",
"depends": ["base_attachment_object_storage"],
"auto_install": False,
"installable": True,
}
+19 -18
View File
@@ -29,10 +29,10 @@ fields.Field.__doc__ += """
class FileURL(fields.Binary):
_slots = {
'attachment': True, # Override default with True
'storage_location': '', # External storage activated on the system (cf base_attachment_storage) # noqa
'storage_path': '', # Path to be used as storage key (prefix of filename) # noqa
'filename': '', # Field to use to store the filename on ir.attachment
"attachment": True, # Override default with True
"storage_location": "", # External storage activated on the system (cf base_attachment_storage) # noqa
"storage_path": "", # Path to be used as storage key (prefix of filename) # noqa
"filename": "", # Field to use to store the filename on ir.attachment
}
def create(self, record_values):
@@ -46,26 +46,27 @@ class FileURL(fields.Binary):
if not value:
continue
vals = {
'name': self.name,
'res_model': self.model_name,
'res_field': self.name,
'res_id': record.id,
'type': 'binary',
'datas': value,
"name": self.name,
"res_model": self.model_name,
"res_field": self.name,
"res_id": record.id,
"type": "binary",
"datas": value,
}
fname = False
if self.filename:
fname = record[self.filename]
vals['datas_fname'] = fname
vals["datas_fname"] = fname
if fname and self.storage_path:
storage_key = self._build_storage_key(fname)
if not fname:
storage_key = False
env['ir.attachment'].sudo().with_context(
env["ir.attachment"].sudo().with_context(
binary_field_real_user=env.user,
storage_location=self.storage_location,
force_storage_key=storage_key,
).create(vals)
return super().create(record_values)
def write(self, records, value):
for record in records:
@@ -79,21 +80,21 @@ class FileURL(fields.Binary):
storage_location=self.storage_location,
force_storage_key=storage_key,
),
value
value,
)
return True
def _setup_regular_base(self, model):
super()._setup_regular_base(model)
if self.storage_path:
assert self.filename is not None, \
assert self.filename is not None, (
"Field %s defines storage_path without filename" % self
)
def _build_storage_key(self, filename):
return '/'.join([
self.storage_path.rstrip('/'),
unicodedata.normalize('NFKC', filename)
])
return "/".join(
[self.storage_path.rstrip("/"), unicodedata.normalize("NFKC", filename)]
)
fields.FileURL = FileURL