summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-06-03 15:39:41 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-06-03 15:39:41 +0700
commit3307dcbdb37285bcd43a719a0ecbc1453e4af9df (patch)
tree81103ea011c3689b3c52304ba1f3e05d31a55853
parent50054732da991bdd966f4fba879c33ee853879ff (diff)
upload payments
-rwxr-xr-xfixco_api/models/invoice.py4
-rwxr-xr-xfixco_custom/models/detail_order.py7
-rw-r--r--fixco_custom/models/ir_attachment.py30
-rw-r--r--fixco_custom/models/upload_payments.py2
4 files changed, 38 insertions, 5 deletions
diff --git a/fixco_api/models/invoice.py b/fixco_api/models/invoice.py
index 33d74fa..9553ff0 100755
--- a/fixco_api/models/invoice.py
+++ b/fixco_api/models/invoice.py
@@ -6,7 +6,7 @@ from odoo.exceptions import RedirectWarning, UserError, ValidationError, AccessE
class Invoice(models.Model):
_inherit = 'account.move'
- def _register_payment_automatically(self):
+ def _register_payment_automatically(self, date):
payment_model = self.env['account.payment']
for invoice in self:
@@ -16,7 +16,7 @@ class Invoice(models.Model):
'partner_type': 'customer',
'partner_id': invoice.partner_id.id,
'amount': invoice.amount_residual,
- 'date': invoice.invoice_date,
+ 'date': date,
'journal_id': invoice.partner_id.ginee_journal_id.id or 24,
'payment_method_id': self.env.ref('account.account_payment_method_manual_in').id,
'ref': invoice.name,
diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py
index e3dc7d7..9cbc446 100755
--- a/fixco_custom/models/detail_order.py
+++ b/fixco_custom/models/detail_order.py
@@ -163,16 +163,19 @@ class DetailOrder(models.Model):
for item in items:
product = self.env['product.product'].search(
- [('default_code', '=', item.get('sku'))],
+ [('default_code', '=', item.get('masterSku'))],
limit=1
)
# raise UserError(_("Product not found for SKU: %s") % item.get('sku'))
line_data = {
- 'product_id': product.id,
+ 'product_id': product.id if product else 5792,
'product_uom_qty': item.get('quantity'),
'price_unit': item.get('actualPrice'),
}
+
+ if not product:
+ line_data['name'] = f"{item.get('masterSku')} ({item.get('productName')})"
order_lines.append((0, 0, line_data))
return order_lines
diff --git a/fixco_custom/models/ir_attachment.py b/fixco_custom/models/ir_attachment.py
new file mode 100644
index 0000000..6417fa3
--- /dev/null
+++ b/fixco_custom/models/ir_attachment.py
@@ -0,0 +1,30 @@
+from odoo import api, fields, models, _
+import logging
+
+_logger = logging.getLogger(__name__)
+
+
+class Attachment(models.Model):
+ _inherit = 'ir.attachment'
+
+ @api.autovacuum
+ def _gc_file_store(self):
+ _logger.info("filestore gc checked, removed - override")
+
+ def is_found(self, model, field, id):
+ attachment = self.search([
+ ('res_model', '=', model),
+ ('res_field', '=', field),
+ ('res_id', '=', int(id))
+ ])
+ return True if attachment else False
+
+ def api_image(self, model, field, id):
+ base_url = self.env['ir.config_parameter'].get_param('web.base.url')
+ is_found = self.is_found(model, field, id)
+ return base_url + 'api/image/' + model + '/' + field + '/' + str(id) if is_found else ''
+
+ def api_image_local(self, model, field, id):
+ base_url = self.env['ir.config_parameter'].get_param('web.base.local_url')
+ is_found = self.is_found(model, field, id)
+ return base_url + 'api/image/' + model + '/' + field + '/' + str(id) if is_found else '' \ No newline at end of file
diff --git a/fixco_custom/models/upload_payments.py b/fixco_custom/models/upload_payments.py
index e7599a7..44e2e27 100644
--- a/fixco_custom/models/upload_payments.py
+++ b/fixco_custom/models/upload_payments.py
@@ -78,7 +78,7 @@ class UploadPayments(models.Model):
])
for move in invoice:
- move._register_payment_automatically()
+ move._register_payment_automatically(line.date_invoice)