diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-06-19 17:08:47 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-06-19 17:08:47 +0700 |
| commit | e595c9ce8de2eb8c778b998cef58b2d85c29a6a7 (patch) | |
| tree | 799c57e3e759ad4fe28b188bfbe58870f5159b64 | |
| parent | e59d33ea416afbe5d2e531f524be37c1eeef6015 (diff) | |
| parent | 7ad6f514da84253dfed42efc18c3c9343d7cc052 (diff) | |
Merge branch 'nathan-dev' of bitbucket.org:altafixco/indoteknik-addons into nathan-dev
| -rw-r--r-- | indoteknik_api/controllers/api_v1/sale_order.py | 2 | ||||
| -rw-r--r-- | indoteknik_api/models/account_move.py | 8 | ||||
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 21 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 27 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring.py | 15 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_monitoring_detail.py | 18 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 4 | ||||
| -rw-r--r-- | indoteknik_custom/models/users.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_monitoring.xml | 33 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_monitoring_detail.xml | 34 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 7 |
12 files changed, 111 insertions, 64 deletions
diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 35361ba4..ec33495e 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -246,7 +246,7 @@ class SaleOrder(controller.Controller): parameters = { 'warehouse_id': 8, 'carrier_id': 1, - 'sales_tax_id': 21, + 'sales_tax_id': 23, 'pricelist_id': product_pricelist_default_discount_id, 'payment_term_id': 26, 'team_id': 2, diff --git a/indoteknik_api/models/account_move.py b/indoteknik_api/models/account_move.py index 54e06f84..23a7076c 100644 --- a/indoteknik_api/models/account_move.py +++ b/indoteknik_api/models/account_move.py @@ -6,6 +6,10 @@ class AccountMove(models.Model): _inherit = 'account.move' def api_v1_single_response(self, account_move, context=False): + sale_order = self.env['sale.order'].search([('name', '=', account_move.invoice_origin), ('state', '=', 'done')], limit=1) + amount_residual = account_move.amount_residual + if sale_order.payment_status == 'settlement' or sale_order.payment_status == 'capture': + amount_residual = 0 data = { 'token': self.env['rest.api'].md5_salt(account_move.id, 'account.move'), 'id': account_move.id, @@ -14,7 +18,7 @@ class AccountMove(models.Model): 'payment_term': account_move.invoice_payment_term_id.name or '', 'sales': account_move.invoice_user_id.name, 'amount_total': account_move.amount_total, - 'amount_residual': account_move.amount_residual, + 'amount_residual': amount_residual, 'invoice_date': account_move.invoice_date.strftime('%d/%m/%Y') or '', 'efaktur': True if account_move.efaktur_document else False, } @@ -30,7 +34,7 @@ class AccountMove(models.Model): 'payment_term': account_move.invoice_payment_term_id.name or '', 'sales': account_move.invoice_user_id.name, 'amount_total': account_move.amount_total, - 'amount_residual': account_move.amount_residual, + 'amount_residual': amount_residual, 'invoice_date_due': account_move.invoice_date_due.strftime('%d/%m/%Y') or '', 'customer': res_users.api_address_response(account_move.partner_id), 'products': [], diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 9c480f4c..a4f8f031 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -211,7 +211,28 @@ class ProductProduct(models.Model): usage = fields.Char(string='Usage') specification = fields.Char(string='Specification') material = fields.Char(string='Material') + qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan') + qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan') + def _get_qty_incoming_bandengan(self): + for product in self: + qty_incoming = self.env['stock.move'].search([ + ('product_id', '=', product.id), + ('location_dest_id', '=', 57), + ('state', 'not in', ['done', 'cancel']) + ]) + qty = sum(qty_incoming.mapped('product_uom_qty')) + product.qty_incoming_bandengan = qty + + def _get_qty_onhand_bandengan(self): + for product in self: + qty_onhand = self.env['stock.quant'].search([ + ('product_id', '=', product.id), + ('location_id', '=', 57) + ]) + qty = sum(qty_onhand.mapped('quantity')) + product.qty_onhand_bandengan = qty + # def write(self, vals): # if 'solr_flag' not in vals: # for variant in self: diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 3b94e816..5aedb07b 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -151,38 +151,19 @@ class PurchaseOrder(models.Model): self.order_line.unlink() for order_line in self.sale_order_id.order_line: if order_line.product_id.id and order_line.product_id.id not in products_exception: - for order_line in self.sale_order_id.order_line: - - qty_onhand = self.env['stock.quant'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_id', '=', 57) - ]) + for order_line in self.sale_order_id.order_line: - qty_incoming = self.env['stock.move'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_dest_id', '=', 57), - ('state', 'not in', ['done', 'cancel']) - ]) - - qty_outgoing = self.env['stock.move'].search([ - ('product_id', '=', order_line.product_id.id), - ('location_id', '=', 57), - ('state', 'not in', ['done', 'cancel']) - ]) - - qty_total = sum(qty_onhand.mapped('quantity')) + sum(qty_incoming.mapped('product_uom_qty')) - - qty = qty_total - sum(qty_outgoing.mapped('product_uom_qty')) + qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty suggest = 'harus beli' - if order_line.product_id.virtual_available > order_line.product_qty: + if qty_available > order_line.product_qty: suggest = 'masih cukup' values = { 'order_id': self.id, 'product_id': order_line.product_id.id, 'name': order_line.product_id.display_name, 'product_qty': order_line.product_qty, - 'qty_available_store': qty, + 'qty_available_store': qty_available, 'suggest': suggest, } self.order_line.create(values) diff --git a/indoteknik_custom/models/sale_monitoring.py b/indoteknik_custom/models/sale_monitoring.py index a3265a8b..e79ff9ab 100755 --- a/indoteknik_custom/models/sale_monitoring.py +++ b/indoteknik_custom/models/sale_monitoring.py @@ -20,6 +20,7 @@ class SaleMonitoring(models.Model): date_order = fields.Datetime(string="Date Order") status = fields.Char(string="Status") po_number = fields.Char(string="PO Number") + qty_reserved = fields.Integer(string="Qty Reserved") def init(self): tools.drop_view_if_exists(self.env.cr, self._table) @@ -36,14 +37,14 @@ class SaleMonitoring(models.Model): SUM(smd.qty_po_received) AS qty_po_received, SUM(smd.qty_so_delivered) AS qty_so_delivered, SUM(smd.qty_so_invoiced) AS qty_so_invoiced, + sum(smd.qty_reserved) as qty_reserved, 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_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' + when sum(qty_so_invoiced) = sum(qty_so) then 'Invoiced' + when sum(qty_so_delivered) = sum(qty_so) then 'Delivered' + when sum(qty_reserved) >= sum(qty_so) then 'Siap kirim' + when sum(qty_po) + sum(qty_reserved) - sum(qty_po_received) < sum(qty_so) then 'Belum/Kurang PO' + when sum(qty_po_received) = 0 then 'Belum terima' + when sum(qty_po_received) < sum(qty_po) then 'Terima sebagian' END AS status, get_po_number(smd.sale_order_id) as po_number FROM sale_monitoring_detail smd diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index a578f67b..2bcda50c 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -21,6 +21,7 @@ class SaleMonitoringDetail(models.Model): qty_so_invoiced = fields.Integer(string="Qty SO Invoiced") date_order = fields.Datetime(string="Date Order") status = fields.Char(string="Status") + qty_reserved = fields.Integer(string="Qty Reserved") def init(self): tools.drop_view_if_exists(self.env.cr, self._table) @@ -29,14 +30,12 @@ class SaleMonitoringDetail(models.Model): SELECT *, CASE - WHEN qty_so = qty_so_invoiced then 'Done' - 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' + when qty_so_invoiced = qty_so then 'Invoiced' + when qty_so_delivered = qty_so then 'Delivered' + when qty_reserved >= qty_so then 'Siap kirim' + when qty_po + qty_reserved - qty_po_received < qty_so then 'Belum/Kurang PO' + when qty_po_received = 0 then 'Belum terima' + when qty_po_received < qty_po then 'Terima sebagian' END AS status FROM ( @@ -52,7 +51,8 @@ class SaleMonitoringDetail(models.Model): 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 + get_qty_received(so.id, sol.product_id) AS qty_po_received, + get_qty_reserved(so.id, sol.product_id) as qty_reserved 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 diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e2693688..e99876c2 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -349,8 +349,8 @@ class SaleOrder(models.Model): raise UserError("Invoice harus di Cancel dahulu") elif self.have_outstanding_picking: raise UserError("DO harus di Cancel dahulu") - elif self.have_outstanding_po: - raise UserError("PO harus di Cancel dahulu") + # elif self.have_outstanding_po: + # raise UserError("PO harus di Cancel dahulu") self.approval_status = False return super(SaleOrder, self).action_cancel() diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index 4904a33d..a2074c46 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -9,3 +9,7 @@ class Users(models.Model): is_sales_manager = fields.Boolean(String='Sales Manager', help='Berhak melakukan Approval SO dengan margin 15-25') is_leader = fields.Boolean(String='Leader', help='Berhak Approval SO Margin < 15 dan Approval PO') is_accounting = fields.Boolean(String='Accounting', help='Berhak Approval Internal Use') + + def notify_internal_users(self, message, title): + users = self.search([('share', '=', False)]) + users.notify_info(message=message, title=title)
\ No newline at end of file diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index a4c77c58..7a397ff6 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -43,7 +43,7 @@ <field name="total_so_percent_margin"/> </field> <field name="product_id" position="before"> - <field name="line_no" attrs="{'readonly': 1}"/> + <field name="line_no" attrs="{'readonly': 1}" optional="hide"/> </field> <field name="product_qty" position="before"> <field name="qty_available_store"/> diff --git a/indoteknik_custom/views/sale_monitoring.xml b/indoteknik_custom/views/sale_monitoring.xml index b3b186e9..0a9a5aa5 100755 --- a/indoteknik_custom/views/sale_monitoring.xml +++ b/indoteknik_custom/views/sale_monitoring.xml @@ -13,16 +13,17 @@ <field name="partner_id"/> <field name="user_id"/> <field name="qty_so"/> + <field name="qty_reserved"/> <field name="qty_po"/> <field name="qty_po_received"/> <field name="qty_so_delivered"/> <field name="qty_so_invoiced"/> <field name="status" widget="badge" - decoration-danger="status == 'Belum PO sama sekali' or status == 'Belum PO full'" - decoration-warning="status == 'Belum Received sama sekali' or status == 'Belum Received full'" - decoration-success="status == 'SIAP KIRIM' or status == 'KIRIM SISANYA'" - decoration-info="status == 'Belum Invoiced'" + decoration-danger="status == 'Belum/Kurang PO'" + decoration-warning="status == 'Belum terima' or status == 'Terima sebagian'" + decoration-success="status == 'Siap kirim'" + decoration-info="status == 'Delivered' or status == 'Invoiced'" /> </tree> </field> @@ -41,15 +42,16 @@ <field name="user_id"/> <field name="status" widget="badge" - decoration-danger="status == 'Belum PO sama sekali' or status == 'Belum PO full'" - decoration-warning="status == 'Belum Received sama sekali' or status == 'Belum Received full'" - decoration-success="status == 'SIAP KIRIM' or status == 'KIRIM SISANYA'" - decoration-info="status == 'Belum Invoiced'" + decoration-danger="status == 'Belum/Kurang PO'" + decoration-warning="status == 'Belum terima' or status == 'Terima sebagian'" + decoration-success="status == 'Siap kirim'" + decoration-info="status == 'Delivered' or status == 'Invoiced'" /> <field name="po_number"/> </group> <group> <field name="qty_so"/> + <field name="qty_reserved"/> <field name="qty_po"/> <field name="qty_po_received"/> <field name="qty_so_delivered"/> @@ -61,10 +63,25 @@ </field> </record> + <record id="view_monitoring_filter" model="ir.ui.view"> + <field name="name">sale.monitoring.list.select</field> + <field name="model">sale.monitoring</field> + <field name="priority" eval="15"/> + <field name="arch" type="xml"> + <search string="Search Monitoring"> + <field name="sale_order_id"/> + <field name="partner_id"/> + <field name="user_id"/> + <field name="status"/> + </search> + </field> + </record> + <record id="sale_monitoring_action" model="ir.actions.act_window"> <field name="name">Sale Monitoring</field> <field name="type">ir.actions.act_window</field> <field name="res_model">sale.monitoring</field> + <field name="search_view_id" ref="view_monitoring_filter"/> <field name="view_mode">tree,form</field> </record> diff --git a/indoteknik_custom/views/sale_monitoring_detail.xml b/indoteknik_custom/views/sale_monitoring_detail.xml index b9602abd..824e65e8 100755 --- a/indoteknik_custom/views/sale_monitoring_detail.xml +++ b/indoteknik_custom/views/sale_monitoring_detail.xml @@ -11,16 +11,17 @@ <field name="user_id"/> <field name="product_id"/> <field name="qty_so"/> + <field name="qty_reserved"/> <field name="qty_po"/> <field name="qty_po_received"/> <field name="qty_so_delivered"/> <field name="qty_so_invoiced"/> <field name="status" widget="badge" - decoration-danger="status == 'Belum PO sama sekali' or status == 'Belum PO full'" - decoration-warning="status == 'Belum Received sama sekali' or status == 'Belum Received full'" - decoration-success="status == 'SIAP KIRIM' or status == 'KIRIM SISANYA'" - decoration-info="status == 'Belum Invoiced' or status == 'Done'" + decoration-danger="status == 'Belum/Kurang PO'" + decoration-warning="status == 'Belum terima' or status == 'Terima sebagian'" + decoration-success="status == 'Siap kirim'" + decoration-info="status == 'Delivered' or status == 'Invoiced'" /> </tree> </field> @@ -40,14 +41,15 @@ <field name="product_id"/> <field name="status" widget="badge" - decoration-danger="status == 'Belum PO sama sekali' or status == 'Belum PO full'" - decoration-warning="status == 'Belum Received sama sekali' or status == 'Belum Received full'" - decoration-success="status == 'SIAP KIRIM' or status == 'KIRIM SISANYA'" - decoration-info="status == 'Belum Invoiced'" + decoration-danger="status == 'Belum/Kurang PO'" + decoration-warning="status == 'Belum terima' or status == 'Terima sebagian'" + decoration-success="status == 'Siap kirim'" + decoration-info="status == 'Delivered' or status == 'Invoiced'" /> </group> <group> <field name="qty_so"/> + <field name="qty_reserved"/> <field name="qty_po"/> <field name="qty_po_received"/> <field name="qty_so_delivered"/> @@ -59,10 +61,26 @@ </field> </record> + <record id="view_monitoring_detail_filter" model="ir.ui.view"> + <field name="name">sale.monitoring.detail.list.select</field> + <field name="model">sale.monitoring.detail</field> + <field name="priority" eval="15"/> + <field name="arch" type="xml"> + <search string="Search Monitoring"> + <field name="sale_order_id"/> + <field name="partner_id"/> + <field name="user_id"/> + <field name="product_id"/> + <field name="status"/> + </search> + </field> + </record> + <record id="sale_monitoring_detail_action" model="ir.actions.act_window"> <field name="name">Sale Monitoring Detail</field> <field name="type">ir.actions.act_window</field> <field name="res_model">sale.monitoring.detail</field> + <field name="search_view_id" ref="view_monitoring_detail_filter"/> <field name="view_mode">tree,form</field> </record> diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index ea13c954..b160d9b1 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -19,8 +19,9 @@ type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/> </button> <field name="payment_term_id" position="after"> - <field name="shipping_cost_covered" required="1"/> - <field name="shipping_paid_by" required="1"/> + <field name="create_date" invisible="1"/> + <field name="shipping_cost_covered" attrs="{'required': ['|', ('create_date', '>', '2023-06-15'), ('create_date', '=', False)]}"/> + <field name="shipping_paid_by" attrs="{'required': ['|', ('create_date', '>', '2023-06-15'), ('create_date', '=', False)]}"/> <field name="delivery_amt"/> <field name="fee_third_party"/> <field name="total_percent_margin"/> @@ -62,7 +63,7 @@ <field name="item_percent_margin"/> </xpath> <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="before"> - <field name="line_no" readonly="1"/> + <field name="line_no" readonly="1" optional="hide"/> </xpath> <field name="amount_total" position="after"> <field name="grand_total"/> |
