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 /indoteknik_custom/models/sales_outstanding.py | |
| parent | 0d5114af051fed9575bc0d108a0fa14a13875f1b (diff) | |
add sales outstanding for monitoring outgoing qty, and add sales person, purchaser
Diffstat (limited to 'indoteknik_custom/models/sales_outstanding.py')
| -rw-r--r-- | indoteknik_custom/models/sales_outstanding.py | 33 |
1 files changed, 33 insertions, 0 deletions
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) |
