diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-03 10:51:25 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-07-03 10:51:25 +0700 |
| commit | 642489c10420956088733db92cf1a8e5e70b9748 (patch) | |
| tree | d42a600bcffa02b88c1d5df7fa696e872a48e3b3 | |
| parent | b5bf14e4b11353faf3ca0afe2c836c3b5468478a (diff) | |
| parent | 53b7bd51793802ebaa5e1bb9b8d525547158fe8b (diff) | |
Merge branch 'nathan-dev' of bitbucket.org:altafixco/indoteknik-addons into nathan-dev
| -rw-r--r-- | indoteknik_api/controllers/api_v1/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/activity.py | 18 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/sale_order.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/controller.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/delivery_order.py | 3 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 28 | ||||
| -rw-r--r-- | indoteknik_custom/views/delivery_order.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 1 |
8 files changed, 57 insertions, 3 deletions
diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py index d05cdf3a..2afefb34 100644 --- a/indoteknik_api/controllers/api_v1/__init__.py +++ b/indoteknik_api/controllers/api_v1/__init__.py @@ -1,3 +1,4 @@ +from . import activity from . import banner from . import blog from . import cart diff --git a/indoteknik_api/controllers/api_v1/activity.py b/indoteknik_api/controllers/api_v1/activity.py new file mode 100644 index 00000000..142db845 --- /dev/null +++ b/indoteknik_api/controllers/api_v1/activity.py @@ -0,0 +1,18 @@ +from .. import controller +from odoo import http +from odoo.http import request + + +class Activity(controller.Controller): + @http.route('/api/v1/activity', auth='public', csrf=False, methods=['POST', 'OPTIONS']) + @controller.Controller.must_authorized() + def create_user_activity(self, **kw): + user_data = self.verify_user_token() + user_id = user_data['user_id'] if user_data else False + request.env['user.activity.log'].create({ + 'page_title': kw.get('page_title', ''), + 'url': kw.get('url', ''), + 'res_user_id': user_id, + 'ip_address': kw.get('ip_address', '') + }) + return self.response(True)
\ No newline at end of file diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 671ff5a8..c1665b72 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -153,6 +153,7 @@ class SaleOrder(controller.Controller): sale_order = request.env['sale.order'].search(domain) if sale_order: sale_order.partner_purchase_order_name = params['value']['name'] + sale_order.client_order_ref = params['value']['name'] sale_order.partner_purchase_order_file = params['value']['file'] data = sale_order.id return self.response(data) diff --git a/indoteknik_api/controllers/controller.py b/indoteknik_api/controllers/controller.py index 90bc50ed..0fcf4814 100644 --- a/indoteknik_api/controllers/controller.py +++ b/indoteknik_api/controllers/controller.py @@ -108,7 +108,6 @@ class Controller(http.Controller): return time def response(self, data=[], code=200, description='OK', headers=[]): - request.env['user.activity.log'].record_activity() response = { 'status': { 'code': code, @@ -169,6 +168,12 @@ class Controller(http.Controller): def get_api_token(self, **kw): return self.response(request.env['ir.config_parameter'].sudo().get_param('rest_api_token') or '') + @http.route('/api/ip-address', auth='public', methods=['GET', 'OPTIONS']) + def get_ip_address(self): + address = request.httprequest.remote_addr + address = address if address != '127.0.0.1' else False + return self.response(address) + @http.route('/api/image/<model>/<field>/<id>', auth='public', methods=['GET']) def get_image(self, model, field, id): model = request.env[model].sudo().search([('id', '=', id)], limit=1) diff --git a/indoteknik_custom/models/delivery_order.py b/indoteknik_custom/models/delivery_order.py index 3f8da384..be5fd2e0 100644 --- a/indoteknik_custom/models/delivery_order.py +++ b/indoteknik_custom/models/delivery_order.py @@ -74,6 +74,7 @@ class DeliveryOrderLine(models.TransientModel): carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method') tracking_no = fields.Char(string='Tracking No') delivery_order_id = fields.Many2one('delivery.order', string='Delivery Order') + partner_id = fields.Many2one('res.partner', string='Customer') @api.onchange('name') def onchange_name(self): @@ -98,6 +99,8 @@ class DeliveryOrderLine(models.TransientModel): self.tracking_no = picking.delivery_tracking_no + self.partner_id = picking.partner_id + delivery_type = self.get_delivery_type(picking.driver_departure_date, picking.driver_arrival_date) if delivery_type != 'departure': self.departure_date = picking.driver_departure_date.astimezone(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index bf415dbb..c5169420 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -85,7 +85,14 @@ class SaleOrder(models.Model): ]) sppkp = fields.Char(string="SPPKP") npwp = fields.Char(string="NPWP") + purchase_total = fields.Monetary(string='Purchase Total', compute='_compute_purchase_total') + def _compute_purchase_total(self): + for order in self: + total = 0 + for line in order.order_line: + total += line.vendor_subtotal + order.purchase_total = total def generate_payment_link_midtrans_sales_order(self): # midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox @@ -342,7 +349,7 @@ class SaleOrder(models.Model): # must add product can sell validation if not line.product_id.product_tmpl_id.sale_ok: raise UserError('Product %s belum bisa dijual, harap hubungi finance' % line.product_id.display_name) - if line.product_id.id == 232383: + if line.product_id.id == 224484: raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara')) if not line.vendor_id or not line.purchase_price: raise UserError(_('Isi Vendor dan Harga Beli sebelum Request Approval')) @@ -575,7 +582,7 @@ class SaleOrderLine(models.Model): 'res.partner', string='Vendor', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, change_default=True, index=True, tracking=1, - domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", ) + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",) purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0) purchase_tax_id = fields.Many2one('account.tax', string='Tax', domain=['|', ('active', '=', False), ('active', '=', True)]) @@ -583,6 +590,23 @@ class SaleOrderLine(models.Model): fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) line_no = fields.Integer('No', default=0, copy=False) note_procurement = fields.Char(string='Note', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring") + vendor_subtotal = fields.Float(string='Vendor Subtotal', compute="_compute_vendor_subtotal") + + def _compute_vendor_subtotal(self): + for line in self: + if line.purchase_price > 0 and line.product_uom_qty > 0: + # product = line.product_id + + # if product: + # vendor_price = line.purchase_price + # if line.purchase_tax_id.price_include: + # vendor_price = line.purchase_price + # else: + # vendor_price = line.purchase_price + (line.purchase_price*11/100) + subtotal = line.purchase_price * line.product_uom_qty + line.vendor_subtotal = subtotal + else: + line.vendor_subtotal = 0 def compute_item_margin(self): for line in self: diff --git a/indoteknik_custom/views/delivery_order.xml b/indoteknik_custom/views/delivery_order.xml index 29ca7365..0b2fd576 100644 --- a/indoteknik_custom/views/delivery_order.xml +++ b/indoteknik_custom/views/delivery_order.xml @@ -21,6 +21,7 @@ <field name="arrival_date" readonly="1"/> <field name="carrier_id" readonly="1"/> <field name="tracking_no"/> + <field name="partner_id" readonly="1"/> </tree> </field> </sheet> diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 88fe5d7e..70e3392f 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -69,6 +69,7 @@ <field name="purchase_tax_id" attrs="{'readonly': [('parent.approval_status', '!=', False)]}" domain="[('type_tax_use','=','purchase')]"/> <field name="item_percent_margin"/> <field name="note_procurement" optional="hide"/> + <field name="vendor_subtotal" optional="hide"/> </xpath> <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="before"> <field name="line_no" readonly="1" optional="hide"/> |
