diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-18 15:45:05 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-04-18 15:45:05 +0700 |
| commit | 60d754cb1b2044adafddd4893212028a3264f620 (patch) | |
| tree | 4b034580ffe571245c3b7b51810a50952b70d53d /indoteknik_api/models/res_users.py | |
| parent | 456d4b07e52c3664fd2c22e2b7748cbb2912539d (diff) | |
price tier on user session, variant and product
Diffstat (limited to 'indoteknik_api/models/res_users.py')
| -rw-r--r-- | indoteknik_api/models/res_users.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 5032f3af..b0807e9f 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -5,6 +5,12 @@ class ResUsers(models.Model): _inherit = 'res.users' def api_single_response(self, res_user, with_detail=''): + config = self.env['ir.config_parameter'] + product_pricelist_tier1 = int(config.get_param('product.pricelist.tier1')) + product_pricelist_tier2 = int(config.get_param('product.pricelist.tier2')) + product_pricelist_tier3 = int(config.get_param('product.pricelist.tier3')) + + user_pricelist = res_user.property_product_pricelist data = { 'id': res_user.id, 'parent_id': res_user.parent_id.id or False, @@ -14,8 +20,17 @@ class ResUsers(models.Model): 'phone': res_user.phone or '', 'mobile': res_user.mobile or '', 'external': res_user.share, - 'company': res_user.company_type == 'company' + 'company': res_user.company_type == 'company', + 'pricelist': False } + + if user_pricelist.id == product_pricelist_tier1: + data['pricelist'] = 'tier1' + if user_pricelist.id == product_pricelist_tier2: + data['pricelist'] = 'tier2' + if user_pricelist.id == product_pricelist_tier3: + data['pricelist'] = 'tier3' + if res_user.parent_id: data.update({ 'company': res_user.parent_id.company_type == 'company' }) |
