diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-11 11:51:06 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-11 11:51:06 +0700 |
| commit | 0391f0df5d30cd81b4281c3d5082bf96671bd97b (patch) | |
| tree | 687b99356f5ad4ab6699cfde8684560cb0e3c7fb | |
| parent | 31374ed669121ba6c8ec401f82ad0bfedf07a6d6 (diff) | |
<iman> update code
4 files changed, 27 insertions, 14 deletions
diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index fcf7e4db..ebf5de08 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -333,15 +333,23 @@ class Partner(controller.Controller): 'streetInvoice': ['alias:street_invoice'], 'stateInvoice': ['alias:state_id_invoice'], 'cityInvoice': ['alias:city_id_invoice'], - 'isSameAddrees':['alias:is_same_address'], - 'isSameAddreesStreet': ['alias:is_same_address_street'], }) + # Konversi nilai 'true' ke boolean True + is_same_address = kw.get('isSameAddrees', 'false').lower() == 'true' + is_same_address_street = kw.get('isSameAddreesStreet', 'false').lower() == 'true' + + # Tambahkan nilai yang dikonversi ke params + if kw.get('isSameAddrees') != '': + params['value']['is_same_address'] = is_same_address + if kw.get('isSameAddreesStreet') != '': + params['value']['is_same_address_street'] = is_same_address_street + if not params['valid']: return self.response(code=400, description=params) - # Filter data baru yang dikirim (non-kosong) - new_data = {key: value for key, value in params['value'].items() if value} + # Filter data baru yang dikirim (non-kosong, boolean False tetap masuk) + new_data = {key: value for key, value in params['value'].items() if value != ''} if pengajuan_tempo: # Jika pengajuan_tempo sudah ada, hanya write data baru yang non-kosong @@ -431,7 +439,7 @@ class Partner(controller.Controller): user_tempo_request = [] if tempo_request: user_tempo_request = request.env['user.pengajuan.tempo.request'].create({ - 'user_id': user.id, + 'user_id': id, 'pengajuan_tempo_id': pengajuan_tempo.id, 'user_company_id': partner_id.id, 'tempo_duration': pengajuan_tempo.tempo_duration.id, @@ -496,7 +504,7 @@ class Partner(controller.Controller): return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) - pengajuan_tempo.user_id = user_account.id + # pengajuan_tempo.user_id = id template = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_res_user_company_request_tempo_review') template.send_mail(pengajuan_tempo.id, force_send=True) template2 = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_res_user_company_new_tempo_to_sales') diff --git a/indoteknik_api/controllers/api_v1/state.py b/indoteknik_api/controllers/api_v1/state.py index 598ef70b..958359a7 100644 --- a/indoteknik_api/controllers/api_v1/state.py +++ b/indoteknik_api/controllers/api_v1/state.py @@ -8,7 +8,11 @@ class District(controller.Controller): @http.route(prefix + 'state', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def get_state(self, **kw): + tempo = kw.get('tempo') parameters = [] + if tempo == 'true': + parameters.append(('country_id', '=', 100)) + name = kw.get('name') if name: @@ -18,7 +22,7 @@ class District(controller.Controller): states = request.env['res.country.state'].search(parameters) data = [] for state in states: - data.append({ 'id': state.id, 'name': state.name }) + data.append({ 'id': state.id, 'name': state.name}) return self.response(data) diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 832c21af..452e4763 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -46,8 +46,8 @@ class UserPengajuanTempoRequest(models.Model): user_id = fields.Many2one('res.partner', string='User') user_company_id = fields.Many2one('res.partner', string='Company') pengajuan_tempo_id = fields.Many2one('user.pengajuan.tempo', string='Form Tempo') - tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo', tracking=3, ) - tempo_limit = fields.Char(string='Limit Tempo', tracking=3) + tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo', tracking=3, domain=[('id', 'in', [24, 25, 29, 32])]) + tempo_limit = fields.Integer(string='Limit Tempo', tracking=3) state_tempo = fields.Selection([ ('draft', 'Pengajuan Tempo'), ('approval_sales', 'Approved by Sales Manager'), @@ -70,7 +70,7 @@ class UserPengajuanTempoRequest(models.Model): account_number_tempo = fields.Char(string="Nomor Rekening Bank", related='pengajuan_tempo_id.account_number_tempo', store=True, tracking=True, readonly=False) website_tempo = fields.Char(string='Website', related='pengajuan_tempo_id.website_tempo', store=True, tracking=True, readonly=False) estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun', related='pengajuan_tempo_id.estimasi_tempo', store=True, tracking=True, readonly=False) - tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='pengajuan_tempo_id.tempo_duration', store=True, tracking=True, readonly=False) + tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='pengajuan_tempo_id.tempo_duration', store=True, tracking=True, readonly=False, domain=[('id', 'in', [24, 25, 29, 32])]) tempo_limit_origin = fields.Char(string='Limit Tempo', related='pengajuan_tempo_id.tempo_limit' , store=True, tracking=True, readonly=False) category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', related='pengajuan_tempo_id.category_produk_ids', readonly=False) @@ -287,7 +287,6 @@ class UserPengajuanTempoRequest(models.Model): for tempo in self: if tempo.env.user.id not in (7, 377, 12182): raise UserError("Limit tempo hanya bisa diubah oleh Sales Manager atau Direktur") - def button_approve(self): for tempo in self: if not self.tempo_limit: diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 0e6b6c71..25907a67 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -8,6 +8,8 @@ <field name="user_id"/> <field name="pengajuan_tempo_id"/> <field name="create_date"/> + <field name="tempo_duration" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}"/> + <field name="tempo_limit" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}" placeholder="Contoh format, misalnya '10000000'" widget="monetary" options="{'currency_field': 'currency_id'}"/> <field name="state_tempo" decoration-success="state_tempo == 'approval_director'" decoration-danger="state_tempo == 'reject'" widget="badge" optional="show"/> </tree> </field> @@ -42,7 +44,7 @@ <field name="tempo_duration" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}"/> <field name="tempo_limit" attrs="{'readonly': [('state_tempo', '=', 'approval_director')]}" - placeholder="Contoh format, misalnya '10000000'"/> + placeholder="Contoh format, misalnya '10000000'" widget="monetary" options="{'currency_field': 'currency_id'}"/> </group> </group> <notebook> @@ -253,7 +255,7 @@ <field name="subject">Pengajuan Tempo kamu di Indoteknik.com Telah Disetujui!</field> <field name="email_from">"Indoteknik.com" <noreply@indoteknik.com></field> <field name="reply_to">sales@indoteknik.com</field> - <field name="email_to">${object.pengajuan_tempo_id.user_id.login | safe}</field> + <field name="email_to">${object.user_id.email | safe}</field> <field name="body_html" type="html"> <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;"> <tr><td align="center"> @@ -322,7 +324,7 @@ <field name="subject">Mohon Maaf Pengajuan Tempo anda kami Tolak</field> <field name="email_from">"Indoteknik.com" <noreply@indoteknik.com></field> <field name="reply_to">sales@indoteknik.com</field> - <field name="email_to">${object.pengajuan_tempo_id.user_id.login | safe}</field> + <field name="email_to">${object.user_id.email | safe}</field> <!-- <field name="email_to">sapiabon768@gmail.com</field>--> <field name="body_html" type="html"> <table border="0" cellpadding="0" cellspacing="0" style="padding-top: 16px; background-color: #F1F1F1; font-family:Inter, Helvetica, Verdana, Arial,sans-serif; line-height: 24px; color: #454748; width: 100%; border-collapse:separate;"> |
