From f6afdd8f02676e9f0f16e2363f0065982e1e0c54 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 7 Nov 2024 16:43:33 +0700 Subject: update code quotation status --- indoteknik_api/controllers/api_v1/sale_order.py | 6 +++++- indoteknik_api/models/sale_order.py | 2 ++ indoteknik_custom/models/sale_order.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index e7664c79..99ba2573 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -150,7 +150,8 @@ class SaleOrder(controller.Controller): def partner_checkout_sale_order_by_id(self, **kw): params = self.get_request_params(kw, { 'partner_id': ['number'], - 'id': ['number'] + 'id': ['number'], + 'status': ['boolean'] }) if not params['valid']: return self.response(code=400, description=params) @@ -163,6 +164,9 @@ class SaleOrder(controller.Controller): data = {} sale_order = request.env['sale.order'].search(domain) if sale_order: + if 'status' in params['value']: + sale_order.is_continue_transaction = params['value']['status'] + if sale_order._requires_approval_margin_leader(): sale_order.approval_status = 'pengajuan2' elif sale_order._requires_approval_margin_manager(): diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 725dbb4b..3f9606a5 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -39,6 +39,8 @@ class SaleOrder(models.Model): data['status'] = 'cancel' if sale_order.state in ['draft', 'sent']: data['status'] = 'draft' + if sale_order.is_continue_transaction: + data['status'] = 'waiting' if sale_order.approval_status in ['pengajuan1', 'pengajuan2']: data['status'] = 'waiting' if sale_order.state == 'sale': diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 8e170b1c..ed397301 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -98,6 +98,7 @@ class SaleOrder(models.Model): helper_by_id = fields.Many2one('res.users', 'Helper By') eta_date = fields.Datetime(string='ETA Date', copy=False, compute='_compute_eta_date') flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web') + is_continue_transaction = fields.Boolean(string='Button Transaction', help='Data dari web') web_approval = fields.Selection([ ('company', 'Company'), ('cust_manager', 'Customer Manager'), -- cgit v1.2.3 From 1cf2ec912af62cca22de4c529d1bec154ca33bac Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 8 Nov 2024 13:56:37 +0700 Subject: update quotation website --- indoteknik_api/models/res_users.py | 6 +++++- indoteknik_custom/models/res_partner.py | 13 +++++++++++-- indoteknik_custom/models/sale_order.py | 8 +++++++- indoteknik_custom/models/user_company_request.py | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 230707cb..52a044dc 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -14,6 +14,9 @@ class ResUsers(models.Model): 'manager': 2, 'director': 3 } + partner_tempo = False + if main_partner: + partner_tempo = main_partner.get_check_tempo_partner() data = { 'id': res_user.id, @@ -32,7 +35,8 @@ class ResUsers(models.Model): 'feature': { 'so_approval': main_partner.use_so_approval, 'only_ready_stock': main_partner.use_only_ready_stock - } + }, + 'partner_tempo': partner_tempo } return data diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index b01c7984..76fa06cd 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -1,7 +1,7 @@ from odoo import models, fields, api from odoo.exceptions import UserError, ValidationError from datetime import datetime - +from odoo.http import request class GroupPartner(models.Model): _name = 'group.partner' @@ -224,6 +224,15 @@ class ResPartner(models.Model): def _onchange_customer_type(self): if self.customer_type == 'nonpkp': self.npwp = '00.000.000.0-000.000' - + def get_check_tempo_partner(self): + self.ensure_one() + + partner = self.parent_id or self + + if not partner.property_payment_term_id or 'Tempo' not in partner.property_payment_term_id.name: + return False + + else: + return True diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index ed397301..36e60cfb 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -98,7 +98,7 @@ class SaleOrder(models.Model): helper_by_id = fields.Many2one('res.users', 'Helper By') eta_date = fields.Datetime(string='ETA Date', copy=False, compute='_compute_eta_date') flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web') - is_continue_transaction = fields.Boolean(string='Button Transaction', help='Data dari web') + is_continue_transaction = fields.Boolean(string='Button Transaction', help='Data dari web', compute='_is_continue_transaction') web_approval = fields.Selection([ ('company', 'Company'), ('cust_manager', 'Customer Manager'), @@ -144,6 +144,12 @@ class SaleOrder(models.Model): ('NP', 'Non Pareto') ]) + def _is_continue_transaction(self): + if self.payment_status == 'settlement': + self.is_continue_transaction = True + else: + self.is_continue_transaction = False + def _compute_total_weight(self): total_weight = 0 missing_weight_products = [] diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 86e66934..64e11700 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -74,7 +74,7 @@ class UserCompanyRequest(models.Model): if not self.is_approve and is_approve: if is_approve == 'approved': - self.user_id.parent_id = self.user_company_id.id + self.user_id.parent_id = self.user_company_id.id if self.user_company_id.id else vals.get('user_company_id') self.user_id.customer_type = self.user_company_id.customer_type self.user_id.npwp = self.user_company_id.npwp self.user_id.sppkp = self.user_company_id.sppkp -- cgit v1.2.3 From d0bd4a82c923789a931f9433085f4219c6d7346a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 8 Nov 2024 14:14:54 +0700 Subject: update user tempo make quotation --- indoteknik_custom/models/res_partner.py | 1 - indoteknik_custom/models/sale_order.py | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 76fa06cd..b6427745 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -232,7 +232,6 @@ class ResPartner(models.Model): if not partner.property_payment_term_id or 'Tempo' not in partner.property_payment_term_id.name: return False - else: return True diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 36e60cfb..c00b2f4e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -98,7 +98,7 @@ class SaleOrder(models.Model): helper_by_id = fields.Many2one('res.users', 'Helper By') eta_date = fields.Datetime(string='ETA Date', copy=False, compute='_compute_eta_date') flash_sale = fields.Boolean(string='Flash Sale', help='Data dari web') - is_continue_transaction = fields.Boolean(string='Button Transaction', help='Data dari web', compute='_is_continue_transaction') + is_continue_transaction = fields.Boolean(string='Button Transaction', help='Data dari web') web_approval = fields.Selection([ ('company', 'Company'), ('cust_manager', 'Customer Manager'), @@ -144,11 +144,13 @@ class SaleOrder(models.Model): ('NP', 'Non Pareto') ]) + @api.onchange('payment_status') def _is_continue_transaction(self): - if self.payment_status == 'settlement': - self.is_continue_transaction = True - else: - self.is_continue_transaction = False + if not self.is_continue_transaction: + if self.payment_status == 'settlement': + self.is_continue_transaction = True + else: + self.is_continue_transaction = False def _compute_total_weight(self): total_weight = 0 -- cgit v1.2.3 From c11d6c564db098b3553893406e9f59bbef029feb Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 18 Nov 2024 10:10:03 +0700 Subject: edit code --- indoteknik_api/models/sale_order.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 8e0371a3..16a17200 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -85,6 +85,11 @@ class SaleOrder(models.Model): } product['quantity'] = line.product_uom_qty product['available_quantity'] = line.product_available_quantity + for data_v2 in sale_order.fulfillment_line_v2: + product_v2 = self.env['product.product'].api_single_response(data_v2.product_id) + if product['id'] == product_v2['id']: + product['so_qty'] = data_v2.so_qty + product['reserved_stock_qty'] = data_v2.reserved_stock_qty data_with_detail['products'].append(product) for invoice in sale_order.invoice_ids: if invoice.state == 'posted': -- cgit v1.2.3 From fd5617629243b879e020afbdb2f1957d2e419ae4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 26 Nov 2024 16:56:38 +0700 Subject: update improve --- indoteknik_api/models/product_template.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indoteknik_api/models/product_template.py b/indoteknik_api/models/product_template.py index 75899624..e46e44d3 100644 --- a/indoteknik_api/models/product_template.py +++ b/indoteknik_api/models/product_template.py @@ -7,6 +7,11 @@ class ProductTemplate(models.Model): def api_single_response(self, product_template, with_detail=''): product_pricelist_default_discount_id = self.env['ir.config_parameter'].get_param('product.pricelist.default_discount_id') product_pricelist_default_discount_id = int(product_pricelist_default_discount_id) + voucher = self.get_voucher_pastihemat(product_template.x_manufacture.id) + newVoucherPastiHemat = {"min_purchase": voucher.min_purchase_amount or 0, + "discount_type": voucher.discount_type or '', + "discount_amount": voucher.discount_amount or 0, + "max_discount": voucher.max_discount_amount or 0,} data = { 'id': product_template.id, 'image': self.env['ir.attachment'].api_image('product.template', 'image_128', product_template.id), @@ -18,6 +23,7 @@ class ProductTemplate(models.Model): 'weight': product_template.weight, 'manufacture': self.api_manufacture(product_template), 'categories': self.api_categories(product_template), + "newVoucherPastiHemat": newVoucherPastiHemat } if with_detail != '': -- cgit v1.2.3 From 0080b6b1da5f181cee32fae7bb5166ce65165374 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 29 Nov 2024 09:53:07 +0700 Subject: cr note product promotion --- indoteknik_custom/models/product_template.py | 2 ++ indoteknik_custom/models/promotion/sale_order.py | 11 ++++++----- indoteknik_custom/views/product_template.xml | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 25473ab8..2e80beec 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -61,6 +61,7 @@ class ProductTemplate(models.Model): sni = fields.Boolean(string='SNI') tkdn = fields.Boolean(string='TKDN') short_spesification = fields.Char(string='Short Spesification') + merchandise_ok = fields.Boolean(string='Product Promotion') @api.constrains('name', 'internal_reference', 'x_manufacture') def required_public_categ_ids(self): @@ -377,6 +378,7 @@ class ProductProduct(models.Model): max_qty_reorder = fields.Float(string='Max Qty Reorder', compute='_get_max_qty_reordering_rule') qty_rpo = fields.Float(string='Qty RPO', compute='_get_qty_rpo') plafon_qty = fields.Float(string='Max Plafon', compute='_get_plafon_qty_product') + merchandise_ok = fields.Boolean(string='Product Promotion') def _get_clean_website_description(self): for rec in self: diff --git a/indoteknik_custom/models/promotion/sale_order.py b/indoteknik_custom/models/promotion/sale_order.py index be820c6f..1c31d060 100644 --- a/indoteknik_custom/models/promotion/sale_order.py +++ b/indoteknik_custom/models/promotion/sale_order.py @@ -10,11 +10,12 @@ class SaleOrder(models.Model): for promotion in promotions: program_line = self.env['promotion.program.line'].browse(promotion['program_line_id']) for free_product in program_line.free_product_ids: - self.env['sale.order.line'].create({ - 'order_id': self.id, - 'name': "Free Product " + free_product.product_id.display_name, - 'display_type': 'line_note' - }) + if free_product.product_id.merchandise_ok: + self.env['sale.order.line'].create({ + 'order_id': self.id, + 'name': f"Free Product {free_product.product_id.display_name} Quantity ({free_product.qty})", + 'display_type': 'line_note' + }) def apply_promotion_program(self): userdata = { diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index 5a509ebd..b6599137 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -24,6 +24,12 @@ 0 +
+
+ +
+
{'no_create': True} -- cgit v1.2.3