diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2025-12-23 10:59:19 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2025-12-23 10:59:19 +0700 |
| commit | 739efe5bbcce20b3fdb524d9045a310ffa84c0f1 (patch) | |
| tree | 32fa45c5fac49a558a15ab0e4b2254bc559c6a22 | |
| parent | 56a252e8accd9c330826ea2e8e596792b5925af9 (diff) | |
<Miqdad> action seen purchasing job
| -rw-r--r-- | indoteknik_custom/models/purchasing_job.py | 52 | ||||
| -rw-r--r-- | indoteknik_custom/views/purchasing_job.xml | 11 |
2 files changed, 42 insertions, 21 deletions
diff --git a/indoteknik_custom/models/purchasing_job.py b/indoteknik_custom/models/purchasing_job.py index 3151f0f6..29928bbb 100644 --- a/indoteknik_custom/models/purchasing_job.py +++ b/indoteknik_custom/models/purchasing_job.py @@ -61,11 +61,23 @@ class PurchasingJob(models.Model): @api.depends('so_number') def _get_check_pj(self): - Seen = self.env['purchasing.job.seen'] + seen = self.env['purchasing.job.seen'] for rec in self: - seen = Seen.search([('product_id', '=', rec.product_id.id)], limit=1) + seen = seen.search([('product_id', '=', rec.product_id.id)], limit=1) rec.check_pj = bool(seen and seen.so_snapshot == rec.so_number) + + def _set_as_seen(self): + seen_model = self.env['purchasing.job.seen'] + + for rec in self: + seen_model.create({ + 'user_id': self.env.user.id, + 'product_id': rec.product_id.id, + 'so_snapshot': rec.so_number, + }) + rec.check_pj = True + def unlink(self): # Example: Delete related records from the underlying model underlying_records = self.env['purchasing.job'].search([ @@ -78,7 +90,7 @@ class PurchasingJob(models.Model): states = self.env['purchasing.job.state'].search([ ('purchasing_job_id', '=', self.id), ],limit=1, order='id desc') - + return { 'name': _('Purchasing Job State'), 'view_mode': 'form', @@ -115,12 +127,12 @@ class PurchasingJob(models.Model): END AS purchase_representative_id FROM v_procurement_monitoring_by_product pmp LEFT JOIN purchasing_job_state pjs ON pjs.purchasing_job_id = pmp.product_id - LEFT JOIN ( + LEFT JOIN ( SELECT vso.product_id, max(sol.vendor_id) as vendor_id FROM v_sales_outstanding vso LEFT JOIN sale_order_line sol ON sol.id = vso.sale_line_id - group by vso.product_id + group by vso.product_id ) sub ON sub.product_id = pmp.product_id WHERE pmp.action = 'kurang'::text AND sub.vendor_id IS NOT NULL GROUP BY pmp.product_id, pmp.brand, pmp.item_code, pmp.product, pmp.action, sub.vendor_id, pmp.so_number; @@ -132,7 +144,7 @@ class PurchasingJob(models.Model): 'product_ids': [x.id for x in self] } return action - + def generate_request_po(self): # print(1) # TODO create document automatic purchase @@ -180,7 +192,7 @@ class PurchasingJob(models.Model): class OutstandingSales(models.Model): _name = 'v.sales.outstanding' - _auto = False + _auto = False _rec_name = 'move_id' id = fields.Integer() @@ -205,21 +217,21 @@ class OutstandingSales(models.Model): tools.drop_view_if_exists(self.env.cr, self._table) self.env.cr.execute(""" CREATE OR REPLACE VIEW v_sales_outstanding AS ( - select sm.id, - sm.id as move_id, - sp.id as picking_id, - sm.product_id, - so.id as sale_id, - sol.id as sale_line_id, - rp.id as partner_id, - so.user_id as salesperson_id, + select sm.id, + sm.id as move_id, + sp.id as picking_id, + sm.product_id, + so.id as sale_id, + sol.id as sale_line_id, + rp.id as partner_id, + so.user_id as salesperson_id, so.partner_invoice_id, - sp.origin, - rp2.name as salesperson, - coalesce(pp.default_code, pt.default_code) as item_code, + sp.origin, + rp2.name as salesperson, + coalesce(pp.default_code, pt.default_code) as item_code, pt.name as product, - sm.product_uom_qty as outgoing, - xm.x_name as brand, + sm.product_uom_qty as outgoing, + xm.x_name as brand, rp.name as invoice_partner, so.create_date as sale_order_create_date from stock_move sm diff --git a/indoteknik_custom/views/purchasing_job.xml b/indoteknik_custom/views/purchasing_job.xml index 2466e7be..6b8baa53 100644 --- a/indoteknik_custom/views/purchasing_job.xml +++ b/indoteknik_custom/views/purchasing_job.xml @@ -98,6 +98,15 @@ <field name="code">action = records.open_form_multi_generate_request_po()</field> </record> + <record id="purchasing_job_action_seen_ir_actions_server" model="ir.actions.server"> + <field name="name">Seen Selected Job</field> + <field name="model_id" ref="model_v_purchasing_job"/> + <field name="binding_model_id" ref="model_v_purchasing_job"/> + <field name="binding_view_types">form,list</field> + <field name="state">code</field> + <field name="code">action = records._set_as_seen()</field> + </record> + <menuitem id="menu_purchasing_job" name="Purchasing Job" @@ -106,4 +115,4 @@ action="v_purchasing_job_action" /> -</odoo>
\ No newline at end of file +</odoo> |
