From 27ae2de4c1deea61dc0891379c8c294e4399b5f7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 18 Jun 2025 11:50:20 +0700 Subject: sale pricelist, customer type, end line bundling --- fixco_custom/__manifest__.py | 1 + fixco_custom/models/__init__.py | 1 + fixco_custom/models/detail_order.py | 11 +++++-- fixco_custom/models/partner.py | 5 +++ fixco_custom/models/sale_pricelist.py | 31 +++++++++++++++++ fixco_custom/security/ir.model.access.csv | 1 + fixco_custom/views/account_move.xml | 10 +++--- fixco_custom/views/res_partner.xml | 1 + fixco_custom/views/sale_pricelist.xml | 55 +++++++++++++++++++++++++++++++ 9 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 fixco_custom/models/sale_pricelist.py create mode 100644 fixco_custom/views/sale_pricelist.xml (limited to 'fixco_custom') diff --git a/fixco_custom/__manifest__.py b/fixco_custom/__manifest__.py index ffcbb6a..7552daf 100755 --- a/fixco_custom/__manifest__.py +++ b/fixco_custom/__manifest__.py @@ -28,6 +28,7 @@ 'views/stock_picking_print_picking_list.xml', 'views/print_picking_list.xml', 'views/uangmuka_penjualan.xml', + 'views/sale_pricelist.xml', ], 'demo': [], 'css': [], diff --git a/fixco_custom/models/__init__.py b/fixco_custom/models/__init__.py index 6ef28e0..5ea3cef 100755 --- a/fixco_custom/models/__init__.py +++ b/fixco_custom/models/__init__.py @@ -9,6 +9,7 @@ from . import sale_order_multi_invoices from . import account_move from . import upload_payments from . import purchase_pricelist +from . import sale_pricelist from . import shipment_group from . import stock_picking_shipment_group from . import print_picking_list diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index acac8e6..b2f7625 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -85,7 +85,7 @@ class DetailOrder(models.Model): # Cek status response if response.status_code == 200: data = response.json() - self.detail_order = json.dumps(data) + self.detail_order = json.dumps(data, indent=4, sort_keys=True) self.execute_status = 'detail_order' else: self.write({ @@ -172,7 +172,7 @@ class DetailOrder(models.Model): if product and item.get('masterSkuType') == 'BUNDLE': order_lines.append((0, 0, { 'display_type': 'line_note', - 'name': f"Bundle: {item.get('productName')}", + 'name': f"Bundle: {item.get('productName')}, Qty: {item.get('quantity')}, Master SKU: {item.get('masterSku')}", 'product_uom_qty': 0, 'price_unit': 0, })) @@ -185,6 +185,13 @@ class DetailOrder(models.Model): 'price_unit': bline.price * bline.product_uom_qty if bline.price else item.get('actualPrice'), 'name': f"{bline.variant_id.display_name} (Bundle Component)" if bline.variant_id.display_name else product.name, })) + + order_lines.append((0, 0, { + 'display_type': 'line_note', + 'name': f"End Of Bundling Product", + 'product_uom_qty': 0, + 'price_unit': 0, + })) continue line_data = { diff --git a/fixco_custom/models/partner.py b/fixco_custom/models/partner.py index 52e89de..17d2fd0 100755 --- a/fixco_custom/models/partner.py +++ b/fixco_custom/models/partner.py @@ -9,4 +9,9 @@ class Partner(models.Model): [('digunggung', 'Digunggung'), ('difaktur', 'Faktur Pajak')], string='Transaction Type' + ) + customer_type = fields.Selection( + [('online', 'Online'), + ('offline', 'Offline')], + string='Customer Type' ) \ No newline at end of file diff --git a/fixco_custom/models/sale_pricelist.py b/fixco_custom/models/sale_pricelist.py new file mode 100644 index 0000000..6af81fe --- /dev/null +++ b/fixco_custom/models/sale_pricelist.py @@ -0,0 +1,31 @@ +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + +class SalePricelist(models.Model): + _name = 'sale.pricelist' + _rec_name = 'product_id' + _inherit = ['mail.thread', 'mail.activity.mixin'] + + name = fields.Char(string='Name', compute="_compute_name") + product_id = fields.Many2one('product.product', string="Product", required=True) + price = fields.Float(string='Price', required=True) + + _sql_constraints = [ + ('product_unique', 'unique(product_id)', 'Product sudah ada dalam daftar harga! Pilih product lain.'), + ] + + @api.depends('product_id') + def _compute_name(self): + for record in self: + record.name = record.product_id.display_name + + @api.constrains('product_id') + def _check_product_duplicate(self): + for record in self: + existing = self.search([ + ('product_id', '=', record.product_id.id), + ('id', '!=', record.id) + ], limit=1) + if existing: + raise ValidationError(_('Product %s sudah ada dalam daftar harga (ID: %s).') % + (record.product_id.display_name, existing.id)) \ No newline at end of file diff --git a/fixco_custom/security/ir.model.access.csv b/fixco_custom/security/ir.model.access.csv index bbdea7b..bc0b1f0 100755 --- a/fixco_custom/security/ir.model.access.csv +++ b/fixco_custom/security/ir.model.access.csv @@ -10,6 +10,7 @@ access_account_move,access.account.move,model_account_move,,1,1,1,1 access_upload_payments,access.upload.payments,model_upload_payments,,1,1,1,1 access_upload_payments_line,access.upload.payments.line,model_upload_payments_line,,1,1,1,1 access_purchase_pricelist,access.purchase.pricelist,model_purchase_pricelist,,1,1,1,1 +access_sale_pricelist,access.sale.pricelist,model_sale_pricelist,,1,1,1,1 access_shipment_group,access.shipment.group,model_shipment_group,,1,1,1,1 access_shipment_group_line,access.shipment.group.line,model_shipment_group_line,,1,1,1,1 access_stock_picking_shipment_group,access.stock.picking.shipment_group,model_stock_picking_shipment_group,,1,1,1,1 diff --git a/fixco_custom/views/account_move.xml b/fixco_custom/views/account_move.xml index 1157212..c77d046 100644 --- a/fixco_custom/views/account_move.xml +++ b/fixco_custom/views/account_move.xml @@ -10,15 +10,15 @@ --> - - + + - + - - + + diff --git a/fixco_custom/views/res_partner.xml b/fixco_custom/views/res_partner.xml index a05cf6a..89e2bc0 100755 --- a/fixco_custom/views/res_partner.xml +++ b/fixco_custom/views/res_partner.xml @@ -12,6 +12,7 @@ + diff --git a/fixco_custom/views/sale_pricelist.xml b/fixco_custom/views/sale_pricelist.xml new file mode 100644 index 0000000..cb4ccb7 --- /dev/null +++ b/fixco_custom/views/sale_pricelist.xml @@ -0,0 +1,55 @@ + + + + sale.pricelist.tree + sale.pricelist + + + + + + + + + + sale.pricelist.form + sale.pricelist + +
+ + + + + + + + +
+ + + +
+
+
+
+ + + Sale Pricelist + ir.actions.act_window + sale.pricelist + tree,form + +

+ Add sale Pricelist! +

+
+
+ + +
\ No newline at end of file -- cgit v1.2.3