-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] base_wamas, base_wamas_ubl: Add new modules to handle the WAMAS document #856
Conversation
f7d564b
to
66eca49
Compare
51731c5
to
65dced8
Compare
65dced8
to
7e6eed8
Compare
ccbc5ea
to
e0eb45e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
early comments
@@ -8,6 +8,8 @@ exclude: | | |||
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| | |||
# Maybe reactivate this when all README files include prettier ignore tags? | |||
^README\.md$| | |||
# Ignore the text files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if needed this should be added to the template
from odoo import models | ||
|
||
|
||
class WamasDocumentDefaultField(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add docstrings on all classes and methods to explain what they represent/do
if self.ttype == "str": | ||
res = self._get_string(value) | ||
elif self.ttype == "int": | ||
res = self._get_int(value) | ||
elif self.ttype == "float": | ||
res = self._get_float(value) | ||
elif self.ttype == "date": | ||
res = self._get_date(value) | ||
elif self.ttype == "datetime": | ||
res = self._get_datetime(value) | ||
elif self.ttype == "bool": | ||
res = self._get_bool(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.ttype == "str": | |
res = self._get_string(value) | |
elif self.ttype == "int": | |
res = self._get_int(value) | |
elif self.ttype == "float": | |
res = self._get_float(value) | |
elif self.ttype == "date": | |
res = self._get_date(value) | |
elif self.ttype == "datetime": | |
res = self._get_datetime(value) | |
elif self.ttype == "bool": | |
res = self._get_bool(value) | |
getters = dict( | |
str=self._get_string, | |
int=self._get_int | |
[....] | |
) | |
return getters[self.ttype](value) |
Those methods should be renamed like... _get_value_from_string__[$ttype]
An alternative to the dict of getters is:
handler = getattr(self, f"_get_value_from_string__{self.ttype}`)
return handler(value)
res = value.strip() | ||
|
||
ICP = self.env["ir.config_parameter"] | ||
lst_false = safe_eval(ICP.get_param("wamas_document_list_false_value", ["f"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need params for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's needed, so that user can configure what value they want to get
|
||
res = False | ||
|
||
if result_type == "list_tuple": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of having a different result?
IMO it would be better to have 2 methods...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of having a different result?
- the
list_tuple
:list
is each line of UBL document and eachtuple
(inlist
) is each element in the line -> onelist_tuple
related to one line -> it's so generic to use for any purpose - the
ordered_dict
:ordered_dict
is a line and each item ofordered_dict
is each element in the line -> I use this to build theordered dict
structure for converting wamas -> ubl inbase_wamas_ubl
IMO it would be better to have 2 methods...
I agree, it should be better if have 2 methods, I'll split it into 2 methods
name = fields.Char(required=True) | ||
code = fields.Char(required=True) | ||
ttype = fields.Selection(FIELD_TYPES, "Type", required=True) | ||
len_field = fields.Integer("Length", required=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some help
?
from odoo.tools import file_open, file_path | ||
|
||
|
||
class TestBaseWamas(TransactionCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have full test coverage, possibly via unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I'll do it, if I finish the other main functions
* WAMAS Document Element, to define elements in WAMAS document, such as: WEAK, WEAP... | ||
* WAMAS Document Field, to define fields that WAMAS elment has, there are a lot of fields in a WAMAS element. | ||
* WAMAS Document Default Field, to define default fields of WAMAS document has. | ||
* WAMAS Document Default Field Template, to define the template of default fields of the elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add a CONFIGURE.rst
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo noupdate="0"> | ||
|
||
<record id="ias_get_ubl_version" model="ir.actions.server"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why you need server actions... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because UBL has a lot of templates and we cannot add hard-coding functions, user can add functions that they need for their UBL documents, so I use ir.actions.server
for this purpose.
it's may not right to use ir.actions.server
like this, but user can control their document actively
e0eb45e
to
4787b0c
Compare
No description provided.