diff options
| -rwxr-xr-x | fixco_custom/__manifest__.py | 1 | ||||
| -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 | ||||
| -rwxr-xr-x | fixco_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | fixco_custom/views/account_move.xml | 10 | ||||
| -rwxr-xr-x | fixco_custom/views/res_partner.xml | 1 | ||||
| -rw-r--r-- | fixco_custom/views/sale_pricelist.xml | 55 |
9 files changed, 109 insertions, 7 deletions
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 @@ <field name="sale_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'entry')]}"/> </field> --> <field name="payment_reference" position="after"> - <field name="invoice_marketplace" readonly="1"/> - <field name="transaction_type" readonly="1"/> + <field name="invoice_marketplace" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> + <field name="transaction_type" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> </field> <field name="partner_id" position="after"> - <field name="address" readonly="1"/> + <field name="address" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> </field> <field name="invoice_date" position="after"> - <field name="sale_id" readonly="1"/> - <field name="picking_id" readonly="1"/> + <field name="sale_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> + <field name="picking_id" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/> </field> </field> </record> 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 @@ </field> <field name="property_payment_term_id" position="after"> <field name="transaction_type"/> + <field name="customer_type"/> </field> </field> </record> 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="sale_pricelist_tree" model="ir.ui.view"> + <field name="name">sale.pricelist.tree</field> + <field name="model">sale.pricelist</field> + <field name="arch" type="xml"> + <tree> + <field name="product_id"/> + <field name="price"/> + </tree> + </field> + </record> + + <record id="sale_pricelist_form" model="ir.ui.view"> + <field name="name">sale.pricelist.form</field> + <field name="model">sale.pricelist</field> + <field name="arch" type="xml"> + <form> + <sheet> + <group> + <group> + <field name="product_id"/> + <field name="price"/> + </group> + </group> + </sheet> + <div class="oe_chatter"> + <field name="message_follower_ids" widget="mail_followers"/> + <field name="activity_ids" widget="mail_activity"/> + <field name="message_ids" widget="mail_thread"/> + </div> + </form> + </field> + </record> + + <record id="sale_pricelist_action" model="ir.actions.act_window"> + <field name="name">Sale Pricelist</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">sale.pricelist</field> + <field name="view_mode">tree,form</field> + <field name="help" type="html"> + <p class="o_view_nocontent_smiling_face"> + Add sale Pricelist! + </p> + </field> + </record> + + <menuitem + action="sale_pricelist_action" + id="sale_pricelist" + parent="sale.product_menu_catalog" + name="Sale Pricelist" + sequence="1" + /> +</odoo>
\ No newline at end of file |
