| 1 | from odoo import models |
| 2 | |
| 3 | UOM_TO_UNECE_CODE = { |
| 4 | 'l10n_tr_nilvera.product_uom_pk': 'PK', |
| 5 | 'l10n_tr_nilvera.product_uom_pf': 'PF', |
| 6 | 'l10n_tr_nilvera.product_uom_cr': 'CR', |
| 7 | 'l10n_tr_nilvera.product_uom_standard_cubic_meter': 'SM3', |
| 8 | 'l10n_tr_nilvera.product_uom_sa': 'SA', |
| 9 | 'l10n_tr_nilvera.product_uom_cmq': 'CMQ', |
| 10 | 'l10n_tr_nilvera.product_uom_mlt': 'MLT', |
| 11 | 'l10n_tr_nilvera.product_uom_mmq': 'MMQ', |
| 12 | 'l10n_tr_nilvera.product_uom_cmk': 'CMK', |
| 13 | 'l10n_tr_nilvera.product_uom_bg': 'BG', |
| 14 | 'l10n_tr_nilvera.product_uom_bx': 'BX', |
| 15 | 'l10n_tr_nilvera.product_uom_pr': 'PR', |
| 16 | 'l10n_tr_nilvera.product_uom_mgm': 'MGM', |
| 17 | 'l10n_tr_nilvera.product_uom_mon': 'MON', |
| 18 | 'l10n_tr_nilvera.product_uom_gt': 'GT', |
| 19 | 'l10n_tr_nilvera.product_uom_ann': 'ANN', |
| 20 | 'l10n_tr_nilvera.product_uom_d61': 'D61', |
| 21 | 'l10n_tr_nilvera.product_uom_d62': 'D62', |
| 22 | 'l10n_tr_nilvera.product_uom_pa': 'PA', |
| 23 | 'l10n_tr_nilvera.product_uom_mwh': 'MWH', |
| 24 | 'l10n_tr_nilvera.product_uom_kwh': 'KWH', |
| 25 | 'l10n_tr_nilvera.product_uom_kwt': 'KWT', |
| 26 | 'l10n_tr_nilvera.product_uom_set': 'SET', |
| 27 | } |
| 28 | |
| 29 | |
| 30 | class Uom(models.Model): |
| 31 | _inherit = 'uom.uom' |
| 32 | |
| 33 | def _get_unece_code(self): |
| 34 | """ This depends on the mapping from https://developer.nilvera.com/en/code-lists#birim-kodlari """ |
| 35 | unece_code = super()._get_unece_code() |
| 36 | if unece_code == 'C62': |
| 37 | xml_id = self.get_external_id() |
| 38 | if xml_id and self.id in xml_id: |
| 39 | return UOM_TO_UNECE_CODE.get(xml_id[self.id], 'C62') |
| 40 | return unece_code |