From 9206062d88d5c243351d334cb8ade3ddc51d22ff Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 22 Apr 2024 09:24:14 +0700 Subject: add new fiture to purchasing job --- indoteknik_custom/models/automatic_purchase.py | 3 ++- indoteknik_custom/models/purchase_order_line.py | 34 +++++++++++++++++++++++++ indoteknik_custom/views/automatic_purchase.xml | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 32a7d9dd..94cf686e 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -338,6 +338,7 @@ class AutomaticPurchase(models.Model): purchase_pricelist = self.env['purchase.pricelist'].search(domain, order=orderby, limit=1) vendor_id = purchase_pricelist.vendor_id + taxes = '' price, taxes = automatic_purchase._get_valid_purchase_price(purchase_pricelist) last_po_line = self.env['purchase.order.line'].search([('product_id', '=', job.product_id.id), ('order_id.state', '=', 'done')], order='id desc', limit=1) @@ -467,7 +468,7 @@ class AutomaticPurchase(models.Model): def _get_valid_purchase_price(self, purchase_price): price = 0 - taxes = None + taxes = '' human_last_update = purchase_price.human_last_update or datetime.min system_last_update = purchase_price.system_last_update or datetime.min diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index c2e7a4c7..b9c4011e 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -40,6 +40,40 @@ class PurchaseOrderLine(models.Model): delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') + @api.constrains('product_qty') + def constrains_product_qty(self): + for line in self: + qty_po = 0 + matches_so = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', line.order_id.id), + ('product_id', '=', line.product_id.id), + ]) + + if not matches_so: + continue + + for matches in matches_so: + qty_po += matches.qty_po + + if qty_po == line.product_qty: + continue + + oldest_date_order = min(matches_so.mapped('sale_id.date_order')) + oldest_matches = matches_so.filtered(lambda x: x.sale_id.date_order == oldest_date_order) + matches_to_remove = matches_so - oldest_matches + + if matches_to_remove: + matches_to_remove.unlink() + + def unlink(self): + for line in self: + mathces_so = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', line.order_id.id), + ('product_id', '=', line.product_id.id), + ]) + mathces_so.unlink() + return super(PurchaseOrderLine, self).unlink() + def _compute_is_edit_product_qty(self): for line in self: diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index 360fdd16..a505daa5 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -30,7 +30,7 @@ - + -- cgit v1.2.3 From 901ab091308ec3d575014a7c0540a0cf544702b7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Apr 2024 15:04:57 +0700 Subject: add new ir_sequence for account move --- indoteknik_custom/models/account_move.py | 27 +++++++++++++++++++++++++++ indoteknik_custom/views/account_move.xml | 4 ++++ indoteknik_custom/views/ir_sequence.xml | 11 ++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 94a1ab19..22b637e9 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -57,6 +57,33 @@ class AccountMove(models.Model): is_efaktur_uploaded = fields.Boolean(string="Is eFaktur Uploaded", default=False) already_paid = fields.Boolean(string="Sudah Dibayar?", default=False) delivery_amt_text = fields.Char(string="Delivery Amt Terbilang", compute='compute_delivery_amt_text') + so_shipping_paid_by = fields.Char(string="SO Shipping Paid By", compute='compute_so_shipping_paid_by') + so_shipping_covered_by = fields.Char(string="SO Shipping Covered By", compute='compute_so_shipping_paid_by') + so_delivery_amt = fields.Char(string="SO Delivery Amount", compute='compute_so_shipping_paid_by') + flag_delivery_amt = fields.Boolean(string="Flag Delivery Amount", compute='compute_flag_delivery_amt') + nomor_kwitansi = fields.Char(string="Nomor Kwitansi") + + @api.model + def create(self, vals): + if vals['flag_delivery_amt'] == True: + vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' + else: + vals['nomor_kwitansi'] = None + result = super(AccountMove, self).create(vals) + return result + + def compute_so_shipping_paid_by(self): + for record in self: + record.so_shipping_paid_by = record.sale_id.shipping_paid_by + record.so_shipping_covered_by = record.sale_id.shipping_cost_covered + record.so_delivery_amt = record.sale_id.delivery_amt + + def compute_flag_delivery_amt(self): + for record in self: + if record.sale_id.delivery_amt > 0: + record.flag_delivery_amt = True + else: + record.flag_delivery_amt = False def compute_delivery_amt_text(self): tb = Terbilang() diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index f505ef9d..606a8b24 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -53,6 +53,10 @@ + + + + diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index d52f55ca..af07ba38 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -90,6 +90,15 @@ 1 1 - + + + Nomor Kwitansi + nomor.kwitansi + TRUE + KWT/%(year)s/ + 5 + 1 + 1 + \ No newline at end of file -- cgit v1.2.3 From a88d0c0fb126813e97f6e9bb7c51afee61e3dae2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Apr 2024 15:12:05 +0700 Subject: fix bug account move --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 22b637e9..5afd174f 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -65,7 +65,7 @@ class AccountMove(models.Model): @api.model def create(self, vals): - if vals['flag_delivery_amt'] == True: + if 'flag_delivery_amt' in vals and vals['flag_delivery_amt']: vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' else: vals['nomor_kwitansi'] = None -- cgit v1.2.3 From 5840f4fce3776a6c14a8f46ed156284b301d8af1 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 23 Apr 2024 17:05:14 +0700 Subject: Hot fix sale order page --- indoteknik_custom/views/sale_order.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index c455655b..23905ef7 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -49,7 +49,6 @@ - @@ -187,9 +186,6 @@ - - - -- cgit v1.2.3 From 68c7f85b0bf7b8eb85f5bbffcfe2bbc8a38b7e4e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 24 Apr 2024 13:45:43 +0700 Subject: update purchasing job --- indoteknik_custom/models/account_move.py | 5 +---- indoteknik_custom/models/automatic_purchase.py | 19 ++++++++++++++++++- indoteknik_custom/models/purchase_order_line.py | 10 ++++++++++ indoteknik_custom/views/account_move.xml | 1 + indoteknik_custom/views/automatic_purchase.xml | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 5afd174f..b306b6af 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -65,10 +65,7 @@ class AccountMove(models.Model): @api.model def create(self, vals): - if 'flag_delivery_amt' in vals and vals['flag_delivery_amt']: - vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' - else: - vals['nomor_kwitansi'] = None + vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' result = super(AccountMove, self).create(vals) return result diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 94cf686e..70b6969e 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -252,14 +252,24 @@ class AutomaticPurchase(models.Model): 'suggest': product._get_po_suggest(line.qty_purchase), 'product_uom_qty': line.qty_purchase, 'price_unit': line.last_price, + 'taxes_id': [line.taxes_id.id], # 'so_line_id': [sales.sale_line_id.id for sales in sales_match], } new_po_line = self.env['purchase.order.line'].create([param_line]) line.current_po_id = new_po.id line.current_po_line_id = new_po_line.id + self.update_purchase_price_so_line(line) self.create_purchase_order_sales_match(new_po) + def update_purchase_price_so_line(self, apo): + sales_match = self.env['automatic.purchase.sales.match'].search([ + ('automatic_purchase_id', '=', self.id), + ('product_id', '=', apo.product_id.id), + ]) + + for sales in sales_match: + sales.sale_line_id.purchase_price = apo.last_price def create_purchase_order_sales_match(self, purchase_order): matches_so_product_ids = [line.product_id.id for line in purchase_order.order_line] @@ -360,7 +370,8 @@ class AutomaticPurchase(models.Model): automatic_purchase.notification = "Automatic PO Created %s Lines" % count automatic_purchase._create_sales_matching() automatic_purchase._create_sync_purchasing_job(jobs) - print(1) + + return automatic_purchase.id def _create_sales_matching(self): for line in self.purchase_lines: @@ -375,6 +386,10 @@ class AutomaticPurchase(models.Model): ('product_id', '=', sale.product_id.id), ]) + price_so = self.env['sale.order.line'].search([ + ('id', '=', sale.sale_line_id.id), + ]) + if existing_match: continue @@ -390,6 +405,7 @@ class AutomaticPurchase(models.Model): 'product_id': sale.product_id.id, 'qty_so': sale.outgoing, 'qty_po': line.qty_purchase, + 'purchase_price': price_so.purchase_price, }]) def _create_sync_purchasing_job(self, jobs): @@ -541,6 +557,7 @@ class AutomaticPurchaseSalesMatch(models.Model): product_id = fields.Many2one('product.product', string='Product') qty_so = fields.Float(string='Qty SO') qty_po = fields.Float(string='Qty PO') + purchase_price = fields.Float(string='Purchase Price SO') class SyncPurchasingJob(models.Model): diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index b9c4011e..93b235d8 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -40,6 +40,16 @@ class PurchaseOrderLine(models.Model): delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') + @api.constrains('purchase_price') + def constrains_purchase_price(self): + for line in self: + matches_so = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', line.order_id.id), + ('product_id', '=', line.product_id.id), + ]) + + line.purchase_price = matches_so.sale_line_id.purchase_price + @api.constrains('product_qty') def constrains_product_qty(self): for line in self: diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 606a8b24..1be6d118 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -50,6 +50,7 @@ + diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index a505daa5..71d292c9 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -52,6 +52,7 @@ + -- cgit v1.2.3 From 9441cb7145af70b1e5a4175c9e15b076bab3fdf0 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 24 Apr 2024 13:54:41 +0700 Subject: Fix voucher greater than total --- indoteknik_custom/models/voucher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/voucher.py b/indoteknik_custom/models/voucher.py index 588e9ac5..66f763e0 100644 --- a/indoteknik_custom/models/voucher.py +++ b/indoteknik_custom/models/voucher.py @@ -153,7 +153,7 @@ class Voucher(models.Model): discount_all = total['all'] * decimal_discount result['all'] = min(discount_all, self.max_discount_amount) if self.max_discount_amount > 0 else discount_all else: - result['all'] = self.discount_amount + result['all'] = min(self.discount_amount, total['all']) return result @@ -169,7 +169,7 @@ class Voucher(models.Model): discount_brand = total_brand * decimal_discount discount_brand = min(discount_brand, line.max_discount_amount) if line.max_discount_amount > 0 else discount_brand else: - discount_brand = line.discount_amount + discount_brand = min(line.discount_amount, total_brand) result['brand'][manufacture_id] = round(discount_brand, 2) result['all'] += discount_brand -- cgit v1.2.3 From 0c577a495101b4f8b6034d3fe097a0a53502d9b2 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 24 Apr 2024 14:27:15 +0700 Subject: fix bug --- indoteknik_custom/models/purchase_order_line.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 93b235d8..624415e3 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -40,15 +40,14 @@ class PurchaseOrderLine(models.Model): delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') - @api.constrains('purchase_price') + @api.constrains('price_unit') def constrains_purchase_price(self): - for line in self: - matches_so = self.env['purchase.order.sales.match'].search([ - ('purchase_order_id', '=', line.order_id.id), - ('product_id', '=', line.product_id.id), - ]) + matches_so = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', self.order_id.id), + ('product_id', '=', self.product_id.id), + ]) - line.purchase_price = matches_so.sale_line_id.purchase_price + matches_so.sale_line_id.purchase_price = self.price_unit @api.constrains('product_qty') def constrains_product_qty(self): -- cgit v1.2.3 From 398bcb1df3b86ba7a0ca83499ae706f1581d02b9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 24 Apr 2024 14:55:07 +0700 Subject: remove readonly real_invoice_id on sale order --- indoteknik_custom/models/sale_order.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index f9f849ca..6e32ca79 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -40,8 +40,7 @@ class SaleOrder(models.Model): domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Dipakai untuk alamat tempel") real_invoice_id = fields.Many2one( - 'res.partner', string='Delivery Invoice Address', readonly=True, required=True, - states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, + 'res.partner', string='Delivery Invoice Address', required=True, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Dipakai untuk alamat tempel") fee_third_party = fields.Float('Fee Pihak Ketiga') -- cgit v1.2.3 From a00567614901730258b6c40693cf811ae7b6e380 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 24 Apr 2024 15:11:23 +0700 Subject: fix bug taxes apo --- indoteknik_custom/models/automatic_purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index 70b6969e..ca64d8b0 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -252,7 +252,7 @@ class AutomaticPurchase(models.Model): 'suggest': product._get_po_suggest(line.qty_purchase), 'product_uom_qty': line.qty_purchase, 'price_unit': line.last_price, - 'taxes_id': [line.taxes_id.id], + 'taxes_id': [line.taxes_id.id] if line.taxes_id else None, # 'so_line_id': [sales.sale_line_id.id for sales in sales_match], } new_po_line = self.env['purchase.order.line'].create([param_line]) -- cgit v1.2.3 From fb23eeec8484031730d8716caf0f8ee0e6a07ed4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 25 Apr 2024 10:53:16 +0700 Subject: fix bug po line --- indoteknik_custom/models/purchase_order_line.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 624415e3..2eeb7d3e 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -42,12 +42,13 @@ class PurchaseOrderLine(models.Model): @api.constrains('price_unit') def constrains_purchase_price(self): - matches_so = self.env['purchase.order.sales.match'].search([ - ('purchase_order_id', '=', self.order_id.id), - ('product_id', '=', self.product_id.id), - ]) + for line in self: + matches_so = self.env['purchase.order.sales.match'].search([ + ('purchase_order_id', '=', line.order_id.id), + ('product_id', '=', line.product_id.id), + ]) - matches_so.sale_line_id.purchase_price = self.price_unit + matches_so.sale_line_id.purchase_price = line.price_unit @api.constrains('product_qty') def constrains_product_qty(self): -- cgit v1.2.3 From e746cf283822f12afe7f7cf11cbf2156b3b689ef Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 25 Apr 2024 15:57:08 +0700 Subject: add tax purchase on matches so apo --- indoteknik_custom/models/automatic_purchase.py | 3 ++- indoteknik_custom/views/automatic_purchase.xml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py index ca64d8b0..dae1c6a4 100644 --- a/indoteknik_custom/models/automatic_purchase.py +++ b/indoteknik_custom/models/automatic_purchase.py @@ -406,6 +406,7 @@ class AutomaticPurchase(models.Model): 'qty_so': sale.outgoing, 'qty_po': line.qty_purchase, 'purchase_price': price_so.purchase_price, + 'purchase_tax_id': price_so.purchase_tax_id.id if price_so.purchase_tax_id.id else None, }]) def _create_sync_purchasing_job(self, jobs): @@ -558,7 +559,7 @@ class AutomaticPurchaseSalesMatch(models.Model): qty_so = fields.Float(string='Qty SO') qty_po = fields.Float(string='Qty PO') purchase_price = fields.Float(string='Purchase Price SO') - + purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) class SyncPurchasingJob(models.Model): _name = 'sync.purchasing.job' diff --git a/indoteknik_custom/views/automatic_purchase.xml b/indoteknik_custom/views/automatic_purchase.xml index 71d292c9..974fbd17 100644 --- a/indoteknik_custom/views/automatic_purchase.xml +++ b/indoteknik_custom/views/automatic_purchase.xml @@ -53,6 +53,7 @@ + -- cgit v1.2.3 From 47043c74e9bc1563052806ffdacf4e12e157890f Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 26 Apr 2024 09:20:51 +0700 Subject: Add sync to solr on program line --- indoteknik_custom/models/solr/promotion_program_line.py | 5 +++++ indoteknik_custom/views/promotion/promotion_program_line.xml | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/indoteknik_custom/models/solr/promotion_program_line.py b/indoteknik_custom/models/solr/promotion_program_line.py index 9cd226fb..36aea1ed 100644 --- a/indoteknik_custom/models/solr/promotion_program_line.py +++ b/indoteknik_custom/models/solr/promotion_program_line.py @@ -75,3 +75,8 @@ class PromotionProgramLine(models.Model): for record in records: record._create_solr_queue('_sync_to_solr') record.solr_flag = 1 + + def action_sync_to_solr(self): + rec_ids = self.env.context.get('active_ids', []) + recs = self.search([('id', 'in', rec_ids)]) + recs._create_solr_queue('_sync_to_solr') \ No newline at end of file diff --git a/indoteknik_custom/views/promotion/promotion_program_line.xml b/indoteknik_custom/views/promotion/promotion_program_line.xml index 025ea35a..7c8e403d 100644 --- a/indoteknik_custom/views/promotion/promotion_program_line.xml +++ b/indoteknik_custom/views/promotion/promotion_program_line.xml @@ -73,6 +73,14 @@ action="promotion_program_line_action" /> + + Sync to Solr + + + code + model.action_sync_to_solr() + + Program Line: Solr Flag to Queue -- cgit v1.2.3 From ac63ed0d7d13e086dd6bddf02e922bad19d1247a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 26 Apr 2024 09:30:02 +0700 Subject: add note on logbook sj --- indoteknik_custom/models/logbook_sj.py | 4 +++- indoteknik_custom/models/report_logbook_sj.py | 1 + indoteknik_custom/views/logbook_sj.xml | 1 + indoteknik_custom/views/report_logbook_sj.xml | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/logbook_sj.py b/indoteknik_custom/models/logbook_sj.py index 9e3daf20..f84619ad 100644 --- a/indoteknik_custom/models/logbook_sj.py +++ b/indoteknik_custom/models/logbook_sj.py @@ -40,7 +40,8 @@ class LogbookSJ(models.TransientModel): 'carrier_id': stock.carrier_id.id, 'tracking_no': stock.delivery_tracking_no, 'partner_id': parent_id, - 'report_logbook_sj_id': report_logbook.id + 'report_logbook_sj_id': report_logbook.id, + 'note': line.note } self.env['report.logbook.sj.line'].create([data]) @@ -69,6 +70,7 @@ class LogbookSJLine(models.TransientModel): logbook_sj_id = fields.Many2one('logbook.sj', string='Logbook SJ') partner_id = fields.Many2one('res.partner', string='Customer') picking_id = fields.Many2one('res.partner', string='Customer') + note = fields.Char(string='Note') @api.onchange('name') def onchange_name(self): diff --git a/indoteknik_custom/models/report_logbook_sj.py b/indoteknik_custom/models/report_logbook_sj.py index f34835ae..093848b5 100644 --- a/indoteknik_custom/models/report_logbook_sj.py +++ b/indoteknik_custom/models/report_logbook_sj.py @@ -67,3 +67,4 @@ class ReportLogbookSJLine(models.Model): sale_id = fields.Many2one('sale.order', string='Sale Order') report_logbook_sj_id = fields.Many2one('report.logbook.sj', string='Logbook SJ') not_exist = fields.Boolean(string='Not Exist') + note = fields.Char(string='Note') diff --git a/indoteknik_custom/views/logbook_sj.xml b/indoteknik_custom/views/logbook_sj.xml index 9eb9aa12..0fa65be5 100644 --- a/indoteknik_custom/views/logbook_sj.xml +++ b/indoteknik_custom/views/logbook_sj.xml @@ -22,6 +22,7 @@ + diff --git a/indoteknik_custom/views/report_logbook_sj.xml b/indoteknik_custom/views/report_logbook_sj.xml index 8221b419..687464f0 100644 --- a/indoteknik_custom/views/report_logbook_sj.xml +++ b/indoteknik_custom/views/report_logbook_sj.xml @@ -31,6 +31,7 @@ + -- cgit v1.2.3 From 697e3397eecca7e84f05965d1f8c4b37aedfb0c6 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 26 Apr 2024 14:59:17 +0700 Subject: Update sale order API with partner's sales Update CRM Lead when cancel PO to Nabila --- indoteknik_api/controllers/api_v1/sale_order.py | 7 ++++++- indoteknik_custom/models/crm_lead.py | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 382a90f4..50f57c9a 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -357,12 +357,17 @@ class SaleOrder(controller.Controller): 'carrier_id': params['value']['carrier_id'], 'delivery_service_type': params['value']['delivery_service_type'], 'customer_type': 'nonpkp', - 'npwp': '0' + 'npwp': '0', + 'user_id': 1180 # User ID: Ima Nurhikmah } if params['value']['type'] == 'sale_order': parameters['approval_status'] = 'pengajuan1' sale_order = request.env['sale.order'].create([parameters]) sale_order.onchange_partner_contact() + + sales_partner = sale_order.partner_id.user_id + if sales_partner and sales_partner not in [25]: # 25: System + parameters['user_id'] = sales_partner.id user_id = params['value']['user_id'] user_cart = request.env['website.user.cart'] diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py index e8721142..9ffd607c 100755 --- a/indoteknik_custom/models/crm_lead.py +++ b/indoteknik_custom/models/crm_lead.py @@ -23,6 +23,15 @@ class CrmLead(models.Model): operator_name = fields.Char('Operator Name', help='Operator yang membalas') order_id = fields.Many2one('sale.order', string='Sales Order', help='Link ke sales order id') + @api.model + def create(self, vals): + rec = super(CrmLead, self).create(vals) + + if rec.email_from == 'api.noreply@altama.co.id' and rec.name.startswith('INDOTEKNIK|ODOO|'): + rec.user_id = 20 # User ID: Nabila Rahmawati + + return rec + @api.onchange('user_id') def _change_salesperson_so(self): if self.order_id: -- cgit v1.2.3 From 5ae667c09db0eaccdaff9607838c9adeb58fb069 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 26 Apr 2024 16:07:58 +0700 Subject: customer commision --- indoteknik_custom/models/commision.py | 3 ++- indoteknik_custom/models/cust_commision.py | 1 + indoteknik_custom/views/cust_commision.xml | 2 ++ indoteknik_custom/views/customer_commision.xml | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index e60fe9a7..7ec2cecc 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -152,6 +152,7 @@ class CustomerCommision(models.Model): account_name = fields.Char(string='Account Name', tracking=3) bank_account = fields.Char(string='Account No', tracking=3) note_transfer = fields.Char(string='Keterangan') + brand_ids = fields.Many2many('x_manufactures', string='Brands') # add status for type of commision, fee, rebate / cashback # include child or not? @@ -250,7 +251,7 @@ class CustomerCommision(models.Model): partners = rec.partner_ids for partner in partners: - brand = [92, 10, 89, 12, 324, 11] + brand = [int(brand) for brand in rec.brand_ids] where = [ ('move_id.move_type', '=', 'out_invoice'), ('move_id.state', '=', 'posted'), diff --git a/indoteknik_custom/models/cust_commision.py b/indoteknik_custom/models/cust_commision.py index da345f04..c3105cfd 100644 --- a/indoteknik_custom/models/cust_commision.py +++ b/indoteknik_custom/models/cust_commision.py @@ -21,6 +21,7 @@ class CustCommision(models.Model): ('cashback', 'Cashback'), ('rebate', 'Rebate'), ], string='Commision Type', required=True) + brand_ids = fields.Many2many('x_manufactures', string='Brands', help='Voucher appplied only for brand') @api.constrains('partner_id') def _check_partner_id(self): diff --git a/indoteknik_custom/views/cust_commision.xml b/indoteknik_custom/views/cust_commision.xml index be58a68c..f080bc60 100644 --- a/indoteknik_custom/views/cust_commision.xml +++ b/indoteknik_custom/views/cust_commision.xml @@ -12,6 +12,7 @@ + @@ -31,6 +32,7 @@ + diff --git a/indoteknik_custom/views/customer_commision.xml b/indoteknik_custom/views/customer_commision.xml index 600ad192..4b74cd34 100644 --- a/indoteknik_custom/views/customer_commision.xml +++ b/indoteknik_custom/views/customer_commision.xml @@ -12,6 +12,7 @@ + @@ -63,6 +64,7 @@ + -- cgit v1.2.3