diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-07-28 15:19:50 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-07-28 15:19:50 +0700 |
| commit | c99a62f139fd7dfad7ffb2911eaaa7e7b95c7dd5 (patch) | |
| tree | ddfecef3f18ea6379ad15dc343da3dfef26fdd5e | |
| parent | 9519acabf66956f7af58a1bdad137c1e86480b57 (diff) | |
push
| -rwxr-xr-x | fixco_custom/models/detail_order.py | 8 | ||||
| -rwxr-xr-x | fixco_custom/models/sale.py | 34 | ||||
| -rw-r--r-- | fixco_custom/models/upload_ginee.py | 2 | ||||
| -rw-r--r-- | fixco_custom/views/account_move.xml | 3 | ||||
| -rwxr-xr-x | fixco_custom/views/sale_order.xml | 9 | ||||
| -rwxr-xr-x | fixco_custom/views/stock_picking.xml | 2 | ||||
| -rw-r--r-- | fixco_custom/views/upload_bills.xml | 2 |
7 files changed, 51 insertions, 9 deletions
diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index e8e87aa..1211aad 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -134,12 +134,10 @@ class DetailOrder(models.Model): def process_queue_item_detail(self, limit=100): domain = [ ('execute_status', '=', 'detail_order'), + '!', '|', - ('detail_order', 'not like', '"orderStatus": "PENDING_PAYMENT"'), - ('json_ginee', 'not like', '"orderStatus": "PENDING_PAYMENT"'), - '|', - ('detail_order', 'not like', '"channel":"BLIBLI_ID"'), - ('json_ginee', 'not like', '"channel":"BLIBLI_ID"'), + ('json_ginee', 'like', '"orderStatus": "PENDING_PAYMENT"'), + ('json_ginee', 'like', '"channel":"BLIBLI_ID"'), ] records = self.search(domain, order='create_date desc', limit=limit) diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index a36be0f..b77c92c 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -11,6 +11,40 @@ class SaleOrder(models.Model): address = fields.Char('Address') note_by_buyer = fields.Char('Note By Buyer') + count_payment = fields.Integer('Count Payment', compute='_compute_count_payment') + + def _compute_count_payment(self): + for rec in self: + if rec.invoice_ids: + invoice_ids_set = set(rec.invoice_ids.ids) + payments = self.env['account.payment'].search([]).filtered( + lambda p: any(inv.id in invoice_ids_set for inv in p.reconciled_invoice_ids) + ) + rec.count_payment = len(payments) + else: + rec.count_payment = 0 + + + def action_view_related_payment(self): + self.ensure_one() + + for rec in self: + if rec.invoice_ids: + invoice_ids_set = set(rec.invoice_ids.ids) + payments = self.env['account.payment'].search([]).filtered( + lambda p: any(inv.id in invoice_ids_set for inv in p.reconciled_invoice_ids) + ) + + return { + 'name': 'Payments', + 'type': 'ir.actions.act_window', + 'res_model': 'account.payment', + 'view_mode': 'tree,form', + 'target': 'current', + 'domain': [('id', 'in', payments.ids)], + } + + def _check_duplicate_order_id(self): for rec in self: so_duplicate = self.search([ diff --git a/fixco_custom/models/upload_ginee.py b/fixco_custom/models/upload_ginee.py index f1ce9ce..8cb07cf 100644 --- a/fixco_custom/models/upload_ginee.py +++ b/fixco_custom/models/upload_ginee.py @@ -286,7 +286,7 @@ class UploadGineeLine(models.Model): if self.env['sale.order'].search([('invoice_mp', 'ilike', line.invoice_marketplace)]): raise UserError(_( - "Invoice Marketplace %s already exists in Detail Orders") % line.invoice_marketplace) + "Invoice Marketplace %s already exists in Sale Orders") % line.invoice_marketplace) data = line._call_api(BATCH_GET_URI, {"orderIds": [line.order_id]}) detail_order = self.env['detail.order'].create({ diff --git a/fixco_custom/views/account_move.xml b/fixco_custom/views/account_move.xml index 3615fb7..daa5707 100644 --- a/fixco_custom/views/account_move.xml +++ b/fixco_custom/views/account_move.xml @@ -10,7 +10,8 @@ <button name="open_reconcile_view" position="after"> <button type="object" name="action_view_related_payment" class="oe_stat_button" - icon="fa-pencil-square-o"> + icon="fa-pencil-square-o" + attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"> <field name="count_payment" widget="statinfo" string="Payments"/> </button> </button> diff --git a/fixco_custom/views/sale_order.xml b/fixco_custom/views/sale_order.xml index 137ded1..0dfd9af 100755 --- a/fixco_custom/views/sale_order.xml +++ b/fixco_custom/views/sale_order.xml @@ -6,6 +6,15 @@ <field name="model">sale.order</field> <field name="inherit_id" ref="sale.view_order_form"/> <field name="arch" type="xml"> + <xpath expr="//button[@name='action_view_invoice']" position="before"> + <button type="object" + name="action_view_related_payment" + class="oe_stat_button" + icon="fa-pencil-square-o" + attrs="{'invisible': [('count_payment', '=', 0)]}" groups="base.group_user"> + <field name="count_payment" widget="statinfo" string="Payments"/> + </button> + </xpath> <button id="action_confirm" position="after"> <button name="open_form_uangmuka_penjualan" string="UangMuka" diff --git a/fixco_custom/views/stock_picking.xml b/fixco_custom/views/stock_picking.xml index c7890f7..073cd47 100755 --- a/fixco_custom/views/stock_picking.xml +++ b/fixco_custom/views/stock_picking.xml @@ -25,7 +25,7 @@ <button name="action_create_invoice_from_mr" string="Create Bill" type="object" - attrs="{'invisible': [('state', '!=', 'done')]}" + attrs="{'invisible': [('state', '!=', 'done'), ('picking_type_code', '!=', 'incoming')]}" /> </button> diff --git a/fixco_custom/views/upload_bills.xml b/fixco_custom/views/upload_bills.xml index a90546f..472fefc 100644 --- a/fixco_custom/views/upload_bills.xml +++ b/fixco_custom/views/upload_bills.xml @@ -52,7 +52,7 @@ <menuitem id="menu_upload_bills" name="Upload Bills" - parent="sale.menu_sale_report" + parent="purchase.menu_procurement_management" sequence="4" action="upload_bills_action" /> |
