summaryrefslogtreecommitdiff
path: root/fixco_custom/models
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_custom/models')
-rwxr-xr-xfixco_custom/models/detail_order.py8
-rwxr-xr-xfixco_custom/models/sale.py34
-rw-r--r--fixco_custom/models/upload_ginee.py2
3 files changed, 38 insertions, 6 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({