Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

tuantrantg
Copy link
Contributor

No description provided.

@tuantrantg tuantrantg marked this pull request as draft November 7, 2023 10:28
@tuantrantg tuantrantg marked this pull request as ready for review November 7, 2023 11:00
@tuantrantg tuantrantg force-pushed the 16.0-add-base_wamas branch 3 times, most recently from 51731c5 to 65dced8 Compare November 10, 2023 07:09
@tuantrantg tuantrantg marked this pull request as draft November 10, 2023 07:32
@tuantrantg tuantrantg changed the title [16.0][ADD] base_wamas: Add new module to handle the WAMAS document [16.0][ADD] base_wamas, base_wamas_ubl: Add new modules to handle the WAMAS document Nov 10, 2023
@tuantrantg tuantrantg force-pushed the 16.0-add-base_wamas branch 7 times, most recently from ccbc5ea to e0eb45e Compare November 15, 2023 10:19
Copy link
Contributor

@simahawk simahawk left a 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
Copy link
Contributor

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):
Copy link
Contributor

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

Comment on lines +55 to +66
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"]))
Copy link
Contributor

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?

Copy link
Contributor Author

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":
Copy link
Contributor

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

Copy link
Contributor Author

@tuantrantg tuantrantg Nov 20, 2023

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 each tuple (in list) is each element in the line -> one list_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 of ordered_dict is each element in the line -> I use this to build the ordered dict structure for converting wamas -> ubl in base_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)
Copy link
Contributor

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):
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

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">
Copy link
Contributor

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... 🤔

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants