diff options
Diffstat (limited to 'fixco_custom/models')
| -rwxr-xr-x | fixco_custom/models/__init__.py | 1 | ||||
| -rwxr-xr-x | fixco_custom/models/detail_order.py | 11 | ||||
| -rwxr-xr-x | fixco_custom/models/partner.py | 5 | ||||
| -rw-r--r-- | fixco_custom/models/sale_pricelist.py | 31 |
4 files changed, 46 insertions, 2 deletions
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 |
