diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-02 15:31:46 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-02 15:31:46 +0700 |
| commit | ddaef3895870403548d032a892a3365de38c016c (patch) | |
| tree | 1ea51a7e51e23dc971aa591cc979b7660e0404e9 | |
| parent | 0d5114af051fed9575bc0d108a0fa14a13875f1b (diff) | |
add sales outstanding for monitoring outgoing qty, and add sales person, purchaser
| -rwxr-xr-x | indoteknik_custom/__manifest__.py | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/models/purchase_outstanding.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/models/sales_outstanding.py | 33 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/purchase_outstanding.xml | 2 | ||||
| -rw-r--r-- | indoteknik_custom/views/sales_outstanding.xml | 74 |
7 files changed, 115 insertions, 2 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index e8e89c1a..c3821327 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -50,6 +50,7 @@ 'views/website_categories_homepage.xml', 'views/sales_target.xml', 'views/purchase_outstanding.xml', + 'views/sales_outstanding.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index f853b1ed..193fd132 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -38,3 +38,4 @@ from . import website_categories_homepage from . import sales_target from . import product_spec from . import purchase_outstanding +from . import sales_outstanding diff --git a/indoteknik_custom/models/purchase_outstanding.py b/indoteknik_custom/models/purchase_outstanding.py index 0cdd9c39..018ab0ec 100644 --- a/indoteknik_custom/models/purchase_outstanding.py +++ b/indoteknik_custom/models/purchase_outstanding.py @@ -9,6 +9,7 @@ class PurchaseOutstanding(models.Model): id = fields.Integer() order_id = fields.Many2one('purchase.order', string='Nomor PO') partner_id = fields.Many2one('res.partner', String='Vendor') + user_id = fields.Many2one('res.users', string='Purchaser') date_order = fields.Datetime(string="Date Order") po_state = fields.Char(string='State') po_status = fields.Char(string='PO Status') @@ -20,7 +21,7 @@ class PurchaseOutstanding(models.Model): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" CREATE OR REPLACE VIEW %s AS( - select pol.id as id, po.id as order_id, po.partner_id, + select pol.id as id, po.id as order_id, po.partner_id, po.user_id, po.date_order, po.state as po_state, po.po_status, pol.product_id, pol.product_uom_qty, pol.qty_received from purchase_order_line pol diff --git a/indoteknik_custom/models/sales_outstanding.py b/indoteknik_custom/models/sales_outstanding.py new file mode 100644 index 00000000..645482ff --- /dev/null +++ b/indoteknik_custom/models/sales_outstanding.py @@ -0,0 +1,33 @@ +from odoo import fields, models, api, tools + + +class SalesOutstanding(models.Model): + _name = 'sales.outstanding' + _auto = False + _rec_name = 'product_id' + + id = fields.Integer() + order_id = fields.Many2one('sale.order', string='Nomor SO') + partner_id = fields.Many2one('res.partner', String='Customer') + user_id = fields.Many2one('res.users', string='Salesperson') + date_order = fields.Datetime(string="Date Order") + so_state = fields.Char(string='State') + so_status = fields.Char(string='SO Status') + product_id = fields.Many2one('product.product', string='Product') + product_uom_qty = fields.Integer(string='Qty SO') + qty_delivered = fields.Integer(string='Qty Delivered') + + def init(self): + tools.drop_view_if_exists(self.env.cr, self._table) + self.env.cr.execute(""" + CREATE OR REPLACE VIEW %s AS( + select sol.id as id, so.id as order_id, so.partner_id, so.user_id, + so.date_order, so.state as so_state, so.so_status, + sol.product_id, sol.product_uom_qty, sol.qty_delivered + from sale_order so + join sale_order_line sol on sol.order_id = so.id + where 1=1 + and sol.product_uom_qty <> sol.qty_delivered + and so_status in ('sebagian','menunggu') + ) + """ % self._table) diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 8c26dd2a..82c5d741 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -19,4 +19,5 @@ access_website_user_wishlist,access.website.user.wishlist,model_website_user_wis access_website_brand_homepage,access.website.brand.homepage,model_website_brand_homepage,,1,1,1,1 access_website_categories_homepage,access.website.categories.homepage,model_website_categories_homepage,,1,1,1,1 access_sales_target,access.sales.target,model_sales_target,,1,1,1,1 -access_purchase_outstanding,access.purchase.outstanding,model_purchase_outstanding,,1,1,1,1
\ No newline at end of file +access_purchase_outstanding,access.purchase.outstanding,model_purchase_outstanding,,1,1,1,1 +access_sales_outstanding,access.sales.outstanding,model_sales_outstanding,,1,1,1,1
\ No newline at end of file diff --git a/indoteknik_custom/views/purchase_outstanding.xml b/indoteknik_custom/views/purchase_outstanding.xml index 52003fd6..dc203744 100644 --- a/indoteknik_custom/views/purchase_outstanding.xml +++ b/indoteknik_custom/views/purchase_outstanding.xml @@ -7,6 +7,7 @@ <tree create="false"> <field name="order_id"/> <field name="partner_id"/> + <field name="user_id"/> <field name="date_order"/> <field name="po_state"/> <field name="po_status"/> @@ -27,6 +28,7 @@ <group> <field name="order_id"/> <field name="partner_id"/> + <field name="user_id"/> <field name="date_order"/> <field name="po_state"/> <field name="po_status"/> diff --git a/indoteknik_custom/views/sales_outstanding.xml b/indoteknik_custom/views/sales_outstanding.xml new file mode 100644 index 00000000..44c2603d --- /dev/null +++ b/indoteknik_custom/views/sales_outstanding.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo> + <record id="sales_outstanding_tree" model="ir.ui.view"> + <field name="name">sales.outstanding.tree</field> + <field name="model">sales.outstanding</field> + <field name="arch" type="xml"> + <tree create="false"> + <field name="order_id"/> + <field name="partner_id"/> + <field name="user_id"/> + <field name="date_order"/> + <field name="so_state"/> + <field name="so_status"/> + <field name="product_id"/> + <field name="product_uom_qty"/> + <field name="qty_delivered"/> + </tree> + </field> + </record> + + <record id="sales_outstanding_form" model="ir.ui.view"> + <field name="name">sales.outstanding.form</field> + <field name="model">sales.outstanding</field> + <field name="arch" type="xml"> + <form create="false" edit="false"> + <sheet> + <group> + <group> + <field name="order_id"/> + <field name="partner_id"/> + <field name="user_id"/> + <field name="date_order"/> + <field name="so_state"/> + <field name="so_status"/> + <field name="product_id"/> + </group> + <group> + <field name="product_uom_qty"/> + <field name="qty_delivered"/> + </group> + </group> + </sheet> + </form> + </field> + </record> + + <record id="view_sales_outstanding_filter" model="ir.ui.view"> + <field name="name">sales.outstanding.list.select</field> + <field name="model">sales.outstanding</field> + <field name="priority" eval="15"/> + <field name="arch" type="xml"> + <search string="Search Sales Outstanding"> + <field name="order_id"/> + <field name="product_id"/> + </search> + </field> + </record> + + <record id="sales_outstanding_action" model="ir.actions.act_window"> + <field name="name">Sales Outstanding</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">sales.outstanding</field> + <field name="search_view_id" ref="view_sales_outstanding_filter"/> + <field name="view_mode">tree,form</field> + </record> + + <menuitem + id="menu_sales_outstanding" + name="Sales Outstanding" + parent="purchase.menu_purchase_products" + sequence="5" + action="sales_outstanding_action" + /> +</odoo>
\ No newline at end of file |
