diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-06 08:59:52 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-06 08:59:52 +0700 |
| commit | d3a28f88b3b94123a3db4ae0873c7e157bbb13f8 (patch) | |
| tree | c2a383be583f41d80f98ee78fddf0641f1ebefbe | |
| parent | 3d20a65942b64f252a10bada016042a3e1fc498a (diff) | |
| parent | 1c18f6c7438537a60f181d089df06a0b4ba915f9 (diff) | |
Merge commit '1c18f6c7438537a60f181d089df06a0b4ba915f9'
21 files changed, 409 insertions, 153 deletions
diff --git a/indoteknik_api/__init__.py b/indoteknik_api/__init__.py new file mode 100644 index 00000000..91c5580f --- /dev/null +++ b/indoteknik_api/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/indoteknik_api/__manifest__.py b/indoteknik_api/__manifest__.py new file mode 100644 index 00000000..b1ebd9a1 --- /dev/null +++ b/indoteknik_api/__manifest__.py @@ -0,0 +1,19 @@ +{ + 'name': 'API Indoteknik', + 'version': '1.0', + 'category': '', + 'sequence': 1, + 'summary': 'API Indoteknik', + 'description': '', + 'author': 'PT. Indoteknik Dotcom Gemilang', + 'website': '', + 'images': ['assets/favicon.ico'], + 'depends': ['base', 'sale'], + 'data': [], + 'demo': [], + 'css': [], + 'installable': True, + 'application': False, + 'auto_install': False, + 'license': '', +} diff --git a/indoteknik_api/controllers/__init__.py b/indoteknik_api/controllers/__init__.py new file mode 100644 index 00000000..4c317fdc --- /dev/null +++ b/indoteknik_api/controllers/__init__.py @@ -0,0 +1,3 @@ +from . import controller +from . import product_controller +from . import sale_order_controller diff --git a/indoteknik_custom/controllers/api_controller.py b/indoteknik_api/controllers/controller.py index faf8b640..fb5f1fce 100644 --- a/indoteknik_custom/controllers/api_controller.py +++ b/indoteknik_api/controllers/controller.py @@ -1,13 +1,13 @@ import datetime import base64 +import json from odoo import http from odoo.http import request -import json from pytz import timezone -class ApiController(http.Controller): +class Controller(http.Controller): def authenticate(self, kw): db = kw.get('db') username = kw.get('username') @@ -34,13 +34,10 @@ class ApiController(http.Controller): return request.make_response(response, [('Content-Type', 'application/json')]) def search_with_api_params(self, model: str, kw, domain=[]): + """ To search data by default API Params if exist """ limit = kw.get('limit', 0) offset = kw.get('offset', 0) order = kw.get('order', '') - # domain = kw.get('domain', []) - # if domain: - # domain = json.loads(domain) - # domain += default_domain return request.env[model].search(domain, limit=int(limit), offset=int(offset), order=order) diff --git a/indoteknik_api/controllers/product_controller.py b/indoteknik_api/controllers/product_controller.py new file mode 100644 index 00000000..0f29971c --- /dev/null +++ b/indoteknik_api/controllers/product_controller.py @@ -0,0 +1,144 @@ +from datetime import datetime +from . import controller +from odoo import http +from odoo.http import request + + +class ProductController(controller.Controller): + prefix_url = '/api/product' + + # TODO: separate function for get manufacture and promotion by product_id + @http.route(prefix_url + '/search', auth='public', methods=['GET']) + def search_product(self, **kw): + self.authenticate(kw) + base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') + + query = kw.get('query') + if not query: + return self.response(code=400, description='Field query is required') + + query = '%' + query.replace(' ', '%') + '%' + domain = [ + ('sale_ok', '=', True), + '|', + ('default_code', 'ilike', query), + ('name', 'ilike', query) + ] + + manufactures = kw.get('manufactures') + if manufactures: + manufactures = [int(x) for x in manufactures.split(',')] + domain.append(('x_manufacture', 'in', manufactures)) + + categories = kw.get('categories') + if categories: + categories = [int(x) for x in categories.split(',')] + domain.append(('public_categ_ids', 'child_of', categories)) + + product_variants = request.env['product.product'].search(domain) + product_variant_ids = [x.id for x in product_variants] + + domain = [('product_variant_ids', 'in', product_variant_ids)] + product_templates = self.search_with_api_params('product.template', kw, domain) + data = { + 'total_records': len(request.env['product.template'].search(domain)), + 'products': [] + } + for product_template in product_templates: + discount_price = 0 + price = product_template.web_price + if price > 0: + if product_template.taxes_id: + if not product_template.taxes_id.price_include: + price += (price * product_template.taxes_id.amount / 100) + else: + price += (price * 11 / 100) + + promotion = self.get_promotion_by_product(product_template) + if len(promotion) > 0: + discount_price = price - (price * promotion['discount_percentage'] / 100) + + manufacture = self.get_manufacture_by_product(product_template) + stock = self.get_stock_by_product(product_template) + + # TODO: remove price and discount_price if old indoteknik not use + data['products'].append({ + 'id': product_template.id, + 'image': base_url + 'api/image/product.template/image_128/' + str(product_template.id) if product_template.image_128 else '', + 'name': product_template.name, + # 'lowest_price': request.env['product.pricelist'].get_lowest_product_variant_price(product_template.id, 4), + 'price': price, + 'discount_price': discount_price, + 'total_variant': len(product_template.product_variant_ids), + 'stock': stock, + 'manufacture': manufacture, + 'promotion': promotion, + }) + return self.response(data) + + @http.route(prefix_url + '/flash_sale', auth='public', methods=['GET']) + def get_flash_sale_product(self, **kw): + self.authenticate(kw) + base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') + product_pricelist_default = request.env['ir.config_parameter'].sudo().get_param('product.pricelist.default') + active_flash_sale = request.env['product.pricelist'].get_active_flash_sale() + data = {} + if active_flash_sale: + flash_sale = { + 'banner': base_url + 'api/image/product.pricelist/banner/' + str(active_flash_sale.id) if active_flash_sale.banner else '', + 'duration': round((active_flash_sale.end_date - datetime.now()).total_seconds()), + 'products': [] + } + product_pricelist_item = request.env['product.pricelist.item'].search([('pricelist_id', '=', active_flash_sale.id)]) + product_variant_ids = [x.product_id.id for x in product_pricelist_item] + product_templates = self.search_with_api_params('product.template', kw, [('product_variant_ids', 'in', product_variant_ids)]) + for product in product_templates: + flash_sale['products'].append({ + 'id': product.id, + 'name': product.name, + 'image': base_url + 'api/image/product.template/image_128/' + str(product.id) if product.image_128 else '', + 'lowest_price': request.env['product.pricelist'].get_lowest_product_variant_price(product.id, int(product_pricelist_default)), + 'stock': self.get_stock_by_product(product), + 'total_variant': len(product.product_variant_ids), + 'manufacture': self.get_manufacture_by_product(product), + 'promotion': self.get_promotion_by_product(product), + }) + data.update({'flash_sale': flash_sale}) + else: + return self.response(code=404, description='Data not found') + return self.response(data) + + def get_stock_by_product(self, product_template: object): + stock = 0 + for product_variant in product_template.product_variant_ids: + stock += product_variant.qty_stock_vendor + return stock + + def get_manufacture_by_product(self, product_template: object): + manufacture = {} + if product_template.x_manufacture: + manufacture.update({ + 'id': product_template.x_manufacture.id, + 'name': product_template.x_manufacture.x_name, + }) + return manufacture + + def get_promotion_by_product(self, product_template: object): + base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') + promotion = {} + if product_template.x_manufacture: + domain = [ + ('rule_products_domain', 'ilike', product_template.x_manufacture.x_name), + ('active', '=', True) + ] + coupon_program = request.env['coupon.program'].search(domain, limit=1) + if coupon_program: + icon_1 = (base_url + 'api/image/coupon.program/x_studio_field_Ifopn/' + str(coupon_program.id)) if coupon_program.x_studio_field_Ifopn else '' + icon_2 = (base_url + 'api/image/coupon.program/x_studio_field_2Ul77/' + str(coupon_program.id)) if coupon_program.x_studio_field_2Ul77 else '' + promotion.update({ + 'name': coupon_program.name, + 'discount_percentage': coupon_program.discount_percentage, + 'icon_1': icon_1, + 'icon_2': icon_2 + }) + return promotion
\ No newline at end of file diff --git a/indoteknik_custom/controllers/api/sale_order.py b/indoteknik_api/controllers/sale_order_controller.py index c00a94d3..741d4bf8 100644 --- a/indoteknik_custom/controllers/api/sale_order.py +++ b/indoteknik_api/controllers/sale_order_controller.py @@ -1,9 +1,9 @@ -from .. import api_controller +from . import controller from odoo import http from odoo.http import request -class SaleOrderApi(api_controller.ApiController): +class SaleOrderController(controller.Controller): @http.route('/api/sale_order/invoiced', auth='public', methods=['GET']) def get_sale_order_invoiced_by_partner_id(self, **kw): self.authenticate(kw) diff --git a/indoteknik_api/models/__init__.py b/indoteknik_api/models/__init__.py new file mode 100644 index 00000000..06f1e1da --- /dev/null +++ b/indoteknik_api/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_pricelist +from . import product_template diff --git a/indoteknik_api/models/product_pricelist.py b/indoteknik_api/models/product_pricelist.py new file mode 100644 index 00000000..3a807f3a --- /dev/null +++ b/indoteknik_api/models/product_pricelist.py @@ -0,0 +1,108 @@ +from odoo import models +from pytz import timezone +from datetime import datetime + + +class ProductPricelist(models.Model): + _inherit = 'product.pricelist' + + def compute_price(self, pricelist_id: int, product_id: int): + """ + Compute price with tax, discount formula, and fixed_price + @param pricelist_id: id of product.pricelist + @param product_id: id of product.product + @return: returns price value from pricelist. + """ + price = 0 + discounts = [] + + is_flash_sale_product = self.is_flash_sale_product(product_id) + if is_flash_sale_product: + pricelist_id = is_flash_sale_product + + is_compute_formula = True + while is_compute_formula: + pricelist = self.env['product.pricelist.item'].search([ + ('pricelist_id', '=', pricelist_id), + ('product_id', '=', product_id) + ], limit=1) + if pricelist: + if pricelist.compute_price == 'formula': + pricelist_id = pricelist.base_pricelist_id.id + discounts.append(pricelist.price_discount) + else: + price = pricelist.fixed_price + is_compute_formula = False + else: + is_compute_formula = False + + product = self.env['product.product'].browse(product_id) + if product: + for tax in product.taxes_id: + if not tax.price_include: + price *= (100 + tax.amount) / 100 + + price_discount = price + for discount in discounts: + price_discount *= (100 - discount) / 100 + + discount_percentage = 0 + if len(discounts) > 0: + discount_percentage = (price - price_discount) / price * 100 + + return { + 'price': price, + 'price_discount': price_discount, + 'discount_percentage': discount_percentage + } + + def get_lowest_product_variant_price(self, product_id, pricelist_id): + """ + @param product_id: id of product.template + @param pricelist_id: id of pricelist which have default price + @return price: object + """ + product_template = self.env['product.template'].browse(product_id) + product_variant_ids = [x.id for x in product_template.product_variant_ids] + product = self.env['product.pricelist.item'].search([ + ('pricelist_id', '=', pricelist_id), + ('product_id', 'in', product_variant_ids) + ], order='fixed_price asc', limit=1) + product_id = 0 + if product: + product_id = product.product_id.id + return self.compute_price(pricelist_id, product_id) + + def get_active_flash_sale(self): + """ + Check whether have active flash sale in range of date + @return: returns pricelist: object + """ + current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + pricelist = self.search([ + ('is_flash_sale', '=', True), + ('start_date', '<=', current_time), + ('end_date', '>=', current_time) + ], limit=1) + return pricelist + + def is_flash_sale_product(self, product_id: int): + """ + Check whether product is flash sale. + @param product_id: id of product.product + @return: returns pricelist_id: int, if product is flash sale. + """ + pricelist = self.get_active_flash_sale() + if pricelist: + pricelist_product_ids = [x.product_id.id for x in pricelist.item_ids] + if product_id in pricelist_product_ids: + return pricelist.id + return False + + # TODO: need testing + def get_active_flash_sale_items(self): + pricelist = self.get_active_flash_sale() + pricelist_item = False + if pricelist: + pricelist_item = [x.product_id for x in pricelist.item_ids] + return pricelist_item diff --git a/indoteknik_api/models/product_template.py b/indoteknik_api/models/product_template.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/indoteknik_api/models/product_template.py diff --git a/indoteknik_custom/__init__.py b/indoteknik_custom/__init__.py index 38718f08..0650744f 100755 --- a/indoteknik_custom/__init__.py +++ b/indoteknik_custom/__init__.py @@ -1,2 +1 @@ from . import models -from . import controllers
\ No newline at end of file diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 0d6da7f1..a00f4ccd 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -14,6 +14,8 @@ 'views/blog_post.xml', 'views/coupon_program.xml', 'views/delivery_order.xml', + 'views/product_pricelist.xml', + 'views/product_pricelist_item.xml', 'views/product_public_category.xml', 'views/product_template.xml', 'views/purchase_order.xml', diff --git a/indoteknik_custom/controllers/__init__.py b/indoteknik_custom/controllers/__init__.py deleted file mode 100644 index 2fd318df..00000000 --- a/indoteknik_custom/controllers/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import api_controller -from . import api diff --git a/indoteknik_custom/controllers/api/__init__.py b/indoteknik_custom/controllers/api/__init__.py deleted file mode 100644 index bd901bd4..00000000 --- a/indoteknik_custom/controllers/api/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import sale_order -from . import product diff --git a/indoteknik_custom/controllers/api/product.py b/indoteknik_custom/controllers/api/product.py deleted file mode 100644 index 3b1c4ce8..00000000 --- a/indoteknik_custom/controllers/api/product.py +++ /dev/null @@ -1,95 +0,0 @@ -import base64 - -from .. import api_controller -from odoo import http -from odoo.http import request - - -class ProductApi(api_controller.ApiController): - @http.route('/api/product/search', auth='public', methods=['GET']) - def search_product(self, **kw): - self.authenticate(kw) - query = kw.get('query') - if not query: - return self.response(code=400, description='Field query is required') - - query = '%' + query.replace(' ', '%') + '%' - domain = [ - ('sale_ok', '=', True), - '|', - ('default_code', 'ilike', query), - ('name', 'ilike', query) - ] - - manufactures = kw.get('manufactures') - if manufactures: - manufactures = [int(x) for x in manufactures.split(',')] - domain.append(('x_manufacture', 'in', manufactures)) - - categories = kw.get('categories') - if categories: - categories = [int(x) for x in categories.split(',')] - domain.append(('public_categ_ids', 'child_of', categories)) - - product_variants = request.env['product.product'].search(domain) - product_variant_ids = [v['id'] for v in product_variants] - - base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') - domain = [ - ('product_variant_ids', 'in', product_variant_ids) - ] - product_templates = self.search_with_api_params('product.template', kw, domain) - data = { - 'total_records': len(request.env['product.template'].search(domain)), - 'products': [] - } - for product_template in product_templates: - stock = 0 - for product_variant in product_template.product_variant_ids: - stock += product_variant.qty_stock_vendor - - discount_price = 0 - price = product_template.web_price - if price > 0: - if product_template.taxes_id: - if not product_template.taxes_id.price_include: - price += (price * product_template.taxes_id.amount / 100) - else: - price += (price * 11 / 100) - - promotion = {} - manufacture = {} - if product_template.x_manufacture: - manufacture.update({ - 'id': product_template.x_manufacture.id, - 'name': product_template.x_manufacture.x_name, - }) - domain = [ - ('rule_products_domain', 'ilike', product_template.x_manufacture.x_name), - ('active', '=', True) - ] - coupon_program = request.env['coupon.program'].search(domain, limit=1) - if coupon_program: - discount_price = price - (price * coupon_program.discount_percentage / 100) - icon_1 = (base_url + 'api/image/coupon.program/x_studio_field_Ifopn/' + str(coupon_program.id)) if coupon_program.x_studio_field_Ifopn else '' - icon_2 = (base_url + 'api/image/coupon.program/x_studio_field_2Ul77/' + str(coupon_program.id)) if coupon_program.x_studio_field_2Ul77 else '' - promotion.update({ - 'name': coupon_program.name, - 'discount_percentage': coupon_program.discount_percentage, - 'icon_1': icon_1, - 'icon_2': icon_2 - }) - - data['products'].append({ - 'id': product_template.id, - 'image': base_url + 'api/image/product.template/image_128/' + str(product_template.id) if product_template.image_128 else '', - 'name': product_template.name, - 'price': price, - 'discount_price': discount_price, - 'total_variant': len(product_template.product_variant_ids), - 'stock': stock, - 'manufacture': manufacture, - 'promotion': promotion, - }) - - return self.response(data) diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 19916fd4..415cd380 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -24,4 +24,5 @@ from . import stock_move from . import stock_picking from . import stock_picking_type from . import delivery_order +from . import product_pricelist from . import users diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py new file mode 100644 index 00000000..b70eb6e6 --- /dev/null +++ b/indoteknik_custom/models/product_pricelist.py @@ -0,0 +1,12 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError + + +class ProductPricelist(models.Model): + _inherit = 'product.pricelist' + + is_flash_sale = fields.Boolean(string='Flash Sale', default=False) + banner = fields.Binary(string='Banner') + start_date = fields.Datetime(string='Start Date') + end_date = fields.Datetime(string='End Date') + diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index 2ef23f39..a837a6bc 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -35,12 +35,12 @@ class SaleMonitoring(models.Model): SUM(smd.qty_so_delivered) AS qty_so_delivered, SUM(smd.qty_so_invoiced) AS qty_so_invoiced, CASE - WHEN SUM(qty_po) <> SUM(qty_so) AND SUM(qty_po) <= 0 THEN 'Belum PO sama sekali' - WHEN SUM(qty_po) <> SUM(qty_so) THEN 'Belum PO full' - WHEN SUM(qty_po_received) <> SUM(qty_po) AND SUM(qty_po_received) <= 0 THEN 'Belum Received sama sekali' - WHEN SUM(qty_po_received) <> SUM(qty_po) THEN 'Belum Received full' - WHEN SUM(qty_so_delivered) <> SUM(qty_so) AND SUM(qty_so_delivered) <= 0 THEN 'SIAP KIRIM' - WHEN SUM(qty_so_delivered) <> SUM(qty_so) THEN 'KIRIM SISANYA' + WHEN SUM(qty_po) < SUM(qty_so) AND SUM(qty_po) <= 0 THEN 'Belum PO sama sekali' + WHEN SUM(qty_po) < SUM(qty_so) THEN 'Belum PO full' + WHEN SUM(qty_po_received) < SUM(qty_so) AND SUM(qty_po_received) <= 0 THEN 'Belum Received sama sekali' + WHEN SUM(qty_po_received) < SUM(qty_so) THEN 'Belum Received full' + WHEN SUM(qty_to_delivered) = SUM(qty_so) THEN 'SIAP KIRIM' + WHEN SUM(qty_to_delivered) < SUM(qty_so) and SUM(qty_to_delivered) > 0 THEN 'KIRIM SISANYA' ELSE 'Belum Invoiced' END AS status, get_po_number(smd.sale_order_id) as po_number diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index d80ec99b..843c7348 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -23,41 +23,42 @@ class SaleMonitoringDetail(models.Model): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" CREATE OR REPLACE VIEW %s AS ( + SELECT + *, + CASE + WHEN qty_po < qty_so AND qty_po <= 0 THEN 'Belum PO sama sekali' + WHEN qty_po < qty_so THEN 'Belum PO full' + WHEN qty_po_received < qty_so and qty_po_received <= 0 THEN 'Belum Received sama sekali' + WHEN qty_po_received < qty_so THEN 'Belum Received full' + WHEN qty_to_delivered = qty_so THEN 'SIAP KIRIM' + WHEN qty_to_delivered < qty_so and qty_to_delivered > 0 THEN 'KIRIM SISANYA' + ELSE 'Belum Invoiced' + END AS status + FROM + ( SELECT - *, - CASE - WHEN qty_po <> qty_so AND qty_po <= 0 THEN 'Belum PO sama sekali' - WHEN qty_po <> qty_so THEN 'Belum PO full' - WHEN qty_po_received <> qty_po and qty_po_received <= 0 THEN 'Belum Received sama sekali' - WHEN qty_po_received <> qty_po THEN 'Belum Received full' - WHEN qty_so_delivered <> qty_so AND qty_so_delivered <= 0 THEN 'SIAP KIRIM' - WHEN qty_so_delivered <> qty_so THEN 'KIRIM SISANYA' - ELSE 'Belum Invoiced' - END AS status - FROM - ( - SELECT - p.id AS id, - so.id AS sale_order_id, - so.partner_id as partner_id, - so.user_id, - p.id AS product_id, - sol.product_uom_qty AS qty_so, - sol.qty_delivered AS qty_so_delivered, - sol.qty_invoiced AS qty_so_invoiced, - so.date_order AS date_order, - get_qty_po(so.id, sol.product_id) AS qty_po, - get_qty_received(so.id, sol.product_id) AS qty_po_received - FROM sale_order so - JOIN sale_order_line sol ON sol.order_id = so.id - JOIN product_product p ON p.id = sol.product_id - JOIN product_template pt ON pt.id = p.product_tmpl_id - WHERE pt.type IN ('consu','product') - AND so.state IN ('sale','done') - AND so.create_date >= '2022-08-10' - ) a - WHERE - a.qty_so <> a.qty_so_delivered - OR a.qty_so <> a.qty_so_invoiced - ) + p.id AS id, + so.id AS sale_order_id, + so.partner_id as partner_id, + so.user_id, + p.id AS product_id, + sol.product_uom_qty AS qty_so, + sol.qty_delivered AS qty_so_delivered, + get_qty_to_delivered(sol.id) as qty_to_delivered, + sol.qty_invoiced AS qty_so_invoiced, + so.date_order AS date_order, + get_qty_po(so.id, sol.product_id) AS qty_po, + get_qty_received(so.id, sol.product_id) AS qty_po_received + FROM sale_order so + JOIN sale_order_line sol ON sol.order_id = so.id + JOIN product_product p ON p.id = sol.product_id + JOIN product_template pt ON pt.id = p.product_tmpl_id + WHERE pt.type IN ('consu','product') + AND so.state IN ('sale','done') + AND so.create_date >= '2022-08-10' + ) a + WHERE + a.qty_so_delivered > a.qty_so_invoiced + or a.qty_to_delivered > 0 + ) """ % self._table) diff --git a/indoteknik_custom/views/product_pricelist.xml b/indoteknik_custom/views/product_pricelist.xml new file mode 100644 index 00000000..18e9835a --- /dev/null +++ b/indoteknik_custom/views/product_pricelist.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<odoo> + <record id="product_pricelist_view_inherit" model="ir.ui.view"> + <field name="name">product.pricelist.view.inherit</field> + <field name="model">product.pricelist</field> + <field name="inherit_id" ref="product.product_pricelist_view"/> + <field name="arch" type="xml"> + <field name="company_id" position="after"> + <field name="is_flash_sale"/> + </field> + <group name="pricelist_settings" position="after"> + <group name="flash_sale_setting"> + <field name="banner" widget="image" attrs="{ + 'invisible': [('is_flash_sale', '=', False)] + }" /> + <field name="start_date" attrs="{ + 'invisible': [('is_flash_sale', '=', False)], + 'required': [('is_flash_sale', '=', True)] + }" /> + <field name="end_date" attrs="{ + 'invisible': [('is_flash_sale', '=', False)], + 'required': [('is_flash_sale', '=', True)] + }" /> + </group> + </group> + </field> + </record> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/product_pricelist_item.xml b/indoteknik_custom/views/product_pricelist_item.xml new file mode 100755 index 00000000..94ba9e4f --- /dev/null +++ b/indoteknik_custom/views/product_pricelist_item.xml @@ -0,0 +1,37 @@ +<odoo> + <data> + <record id="product_pricelist_item_action" model="ir.actions.act_window"> + <field name="name">Product Pricelist Item</field> + <field name="res_model">product.pricelist.item</field> + <field name="view_mode">tree,form</field> + </record> + + <record id="product_pricelist_item_form_view_inherit" model="ir.ui.view"> + <field name="name">product.pricelist.item.form.view.inherit</field> + <field name="model">product.pricelist.item</field> + <field name="inherit_id" ref="product.product_pricelist_item_form_view" /> + <field name="arch" type="xml"> + <field name="applied_on" position="before"> + <field name="pricelist_id" /> + </field> + </field> + </record> + + <record id="product_pricelist_item_view_search_inherit" model="ir.ui.view"> + <field name="name">product.pricelist.item.search.inherit</field> + <field name="model">product.pricelist.item</field> + <field name="inherit_id" ref="product.product_pricelist_item_view_search"/> + <field name="arch" type="xml"> + <field name="pricelist_id" position="before"> + <field name="product_id" string="Products"/> + </field> + </field> + </record> + + <menuitem id="product_pricelist_item" + name="Pricelist Items" + parent="sale.product_menu_catalog" + sequence="2" + action="product_pricelist_item_action"/> + </data> +</odoo>
\ No newline at end of file diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 0abbae94..f83b2a6b 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -26,11 +26,11 @@ <field name="vendor_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/> <field name="purchase_price" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/> <field name="purchase_tax_id" attrs="{'readonly': [('parent.state', 'not in', ['draft', 'sent', 'sale'])]}"/> - <field name="item_percent_margin" groups="sales_team.group_sale_manager"/> + <field name="item_percent_margin"/> </xpath> <field name="amount_total" position="after"> - <field name="total_margin" groups="sales_team.group_sale_manager"/> - <field name="total_percent_margin" groups="sales_team.group_sale_manager"/> + <field name="total_margin"/> + <field name="total_percent_margin"/> </field> <field name="effective_date" position="after"> <field name="carrier_id"/> |
