Skip to content

Commit

Permalink
Merge PR #916 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Feb 1, 2024
2 parents 644353c + 9355414 commit 935e295
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 22 deletions.
11 changes: 8 additions & 3 deletions base_wamas_ubl/lib/wamas/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@

DICT_TUPLE_KEY_RECEPTION = {
("WEAKQ", "WEAPQ"): (
"ubl_template/reception_wea.xml",
"ubl_template/reception.xml",
("WEAKQ", "IvWevk_WevId_WevNr"),
("WEAPQ", "IvWevp_WevId_WevNr"),
),
("KRETKQ", "KRETPQ"): (
"ubl_template/reception_kret.xml",
"ubl_template/return.xml",
("KRETKQ", "IvKretk_KretId_KretNr"),
("KRETPQ", "IvKretp_KretId_KretNr"),
),
Expand All @@ -174,7 +174,12 @@
# CONVERT UNIT CODE
##

LST_FIELD_UNIT_CODE = ["HostEinheit"]
LST_FIELD_UNIT_CODE = [
"HostEinheit",
"Art_Anzeige_Einheit",
"Arte_Einheit",
"ArtEan_EST_Einheit",
]


MAPPING_UNITCODE_WAMAS_TO_UBL = {
Expand Down
10 changes: 10 additions & 0 deletions base_wamas_ubl/lib/wamas/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dotty_dict import Dotty
from freezegun import freeze_time
from utils import (
_set_string_bool,
dict2wamas,
file_open,
file_path,
Expand Down Expand Up @@ -79,6 +80,15 @@ def testGetAddressNameFromDict(self):
self.assertEqual(get_Adrs_Name4(address_elements), "Nom4")
self.assertEqual(get_Adrs_Adr(address_elements), "Adresse")

def test_set_string_bool(self):
# Input is boolean
self.assertEqual(_set_string_bool(False, 1, False), "N")
self.assertEqual(_set_string_bool(True, 1, False), "J")

# Input is string
self.assertEqual(_set_string_bool("N", 1, False), "N")
self.assertEqual(_set_string_bool("J", 1, False), "J")


if __name__ == "__main__":
unittest.main()
7 changes: 6 additions & 1 deletion base_wamas_ubl/lib/wamas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ def _set_string_datetime(val, length, dp, **kwargs):


def _set_string_bool(val, length, dp, **kwargs):
return (val or "N")[:length]
res = "N"
if isinstance(val, str) and val:
res = val[:length]
elif isinstance(val, bool) and val:
res = "J"
return res


def set_value_to_string(val, ttype, length, dp, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions base_wamas_ubl/lib/wamas/wamas_grammar/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"type": "bool",
"length": 1,
"dp": False,
"dict_key": False,
"dict_key": "no_stock_wamas",
"df_val": False,
"df_func": False,
},
Expand Down Expand Up @@ -459,7 +459,7 @@
"type": "float",
"length": 14,
"dp": 6,
"dict_key": "standard_price",
"dict_key": "list_price",
"df_val": False,
"df_func": False,
},
Expand Down
2 changes: 1 addition & 1 deletion base_wamas_ubl/lib/wamas/wamas_grammar/arte.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"type": "float",
"length": 12,
"dp": 3,
"dict_key": "qty",
"dict_key": False,
"df_val": False,
"df_func": False,
},
Expand Down
2 changes: 1 addition & 1 deletion base_wamas_ubl/lib/wamas/wamas_grammar/artean.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"type": "str",
"length": 5,
"dp": False,
"dict_key": False,
"dict_key": "product_uom",
"df_val": False,
"df_func": False,
},
Expand Down
4 changes: 2 additions & 2 deletions base_wamas_ubl/lib/wamas/wamas_grammar/weak.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"length": 5,
"dp": False,
"ubl_path": False,
"df_val": "HOST",
"df_func": False,
"df_val": False,
"df_func": "get_source",
},
"RxWeak_ExtRef": {
"type": "str",
Expand Down
4 changes: 2 additions & 2 deletions base_wamas_ubl/lib/wamas/wamas_grammar/weap.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"length": 5,
"dp": False,
"ubl_path": False,
"df_val": "HOST",
"df_func": False,
"df_val": False,
"df_func": "get_source",
},
"RxWeap_ExtRef": {
"type": "str",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"barcode": "256256256",
"product": "113 113 113",
"product_uom": "C62",
"game_identifier": "N",
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ODOO WAMAS 00000120231221051251ARTEAN001000113 113 113 00000256256256 N
ODOO WAMAS 00000120231221051251ARTEAN001000113 113 113 00000256256256 BOUT N
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"product": "223 224 225",
"qty": 5.0,
"width": 55,
"height": 50,
"weight": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ODOO WAMAS 00000120231221051251ARTE00051000223 224 225 00000000010000055000050Box 000000000001000000 000000000000000000000000 000000005000000000000000N1000000000001000NNN
ODOO WAMAS 00000120231221051251ARTE00051000223 224 225 00000000010000055000050Box 000000000001000000 000000000000000000000000 000000000000000000000000N1000000000001000NNN
12 changes: 6 additions & 6 deletions base_wamas_ubl/tests/samples/UBL2WAMAS-SAMPLE_WEAK_WEAP.wamas
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ODOO WAMAS 00000120230501020000WEAK00050000130377 HOST STDMAN0001040 STDMAN0001040 Chester Reed YourCompany 250 Executive Park Blvd, Suite 3400 250 Executive Park Blvd, Suite 3400 250 Executive Park Blvd, Suite 3400 California 95380 Turlock US (623)-853-7197 wood.corner26@example.com 20230427020000
ODOO WAMAS 00000220230501020000WEAP00045000130377 HOST 0001 0000020001151 00000 NDISPONIBLE 000001536000BOUT NORMAL 20230501020000 202305010200007910063 NNLG
ODOO WAMAS 00000320230501020000WEAP00045000130377 HOST 0002 0000030001156 00000 NDISPONIBLE 000005184000PET NORMAL 20230501020000 202305010200007910105 NNLG
ODOO WAMAS 00000420230501020000WEAP00045000130377 HOST 0003 0000040001160 00000 NDISPONIBLE 000003840000BOUT NORMAL 20230501020000 202305010200007910004 NNLG
ODOO WAMAS 00000520230501020000WEAP00045000130377 HOST 0004 0000050001162 00000 NDISPONIBLE 000003072000PET NORMAL 20230501020000 2023050102000012156876 NNLG
ODOO WAMAS 00000620230501020000WEAP00045000130377 HOST 0005 0000060001176 00000 NDISPONIBLE 000003024000PET NORMAL 20230501020000 202305010200007910044 NNLG
ODOO WAMAS 00000120230501020000WEAK00050000130377 ODOO STDMAN0001040 STDMAN0001040 Chester Reed YourCompany 250 Executive Park Blvd, Suite 3400 250 Executive Park Blvd, Suite 3400 250 Executive Park Blvd, Suite 3400 California 95380 Turlock US (623)-853-7197 wood.corner26@example.com 20230427020000
ODOO WAMAS 00000220230501020000WEAP00045000130377 ODOO 0001 0000020001151 00000 NDISPONIBLE 000001536000BOUT NORMAL 20230501020000 202305010200007910063 NNLG
ODOO WAMAS 00000320230501020000WEAP00045000130377 ODOO 0002 0000030001156 00000 NDISPONIBLE 000005184000PET NORMAL 20230501020000 202305010200007910105 NNLG
ODOO WAMAS 00000420230501020000WEAP00045000130377 ODOO 0003 0000040001160 00000 NDISPONIBLE 000003840000BOUT NORMAL 20230501020000 202305010200007910004 NNLG
ODOO WAMAS 00000520230501020000WEAP00045000130377 ODOO 0004 0000050001162 00000 NDISPONIBLE 000003072000PET NORMAL 20230501020000 2023050102000012156876 NNLG
ODOO WAMAS 00000620230501020000WEAP00045000130377 ODOO 0005 0000060001176 00000 NDISPONIBLE 000003024000PET NORMAL 20230501020000 202305010200007910044 NNLG
2 changes: 1 addition & 1 deletion base_wamas_ubl/tests/test_base_wamas_ubl.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _wamas_ubl_wiz_check(self, input_file, expected_output_file):
wizard.btn_check()
self.assertEqual(wizard.output, str_expected_output)

@freeze_time("2023-05-01")
@freeze_time("2023-05-01 00:00:00")
def _wamas_ubl_wiz_simulate(
self, input_file, expected_output_file, state="success"
):
Expand Down

0 comments on commit 935e295

Please sign in to comment.