summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-10-31 13:58:41 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-10-31 13:58:41 +0700
commitc6483e28695653497b9576ab01877e6d71a4103f (patch)
tree920b4084bd71ac244c113c2c89993d401de29401
parentd8c12d085edbd81d974555780b16421c7b155f7f (diff)
parent57f30e319a3f3c6c6c87418ffb12e44ac6846fe2 (diff)
Merge branch 'production' into iman/pengajuan-tempo
-rw-r--r--indoteknik_api/controllers/api_v1/partner.py6
-rw-r--r--indoteknik_api/models/res_users.py3
-rwxr-xr-xindoteknik_custom/models/crm_lead.py2
-rwxr-xr-xindoteknik_custom/models/purchase_order.py84
-rw-r--r--indoteknik_custom/models/res_partner.py6
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml7
6 files changed, 107 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py
index 27ba186f..1d7c682d 100644
--- a/indoteknik_api/controllers/api_v1/partner.py
+++ b/indoteknik_api/controllers/api_v1/partner.py
@@ -77,6 +77,9 @@ class Partner(controller.Controller):
'district_id': ['number', 'alias:kecamatan_id'],
'sub_district_id': ['number', 'alias:kelurahan_id', 'exclude_if_null'],
'zip': ['required'],
+ 'longtitude': [],
+ 'latitude': [],
+ 'address_map': [],
'alamat_lengkap_text': []
})
@@ -108,6 +111,9 @@ class Partner(controller.Controller):
'city_id': ['required', 'number', 'alias:kota_id'],
'district_id': ['number', 'alias:kecamatan_id'],
'sub_district_id': ['number', 'alias:kelurahan_id', 'exclude_if_null'],
+ 'longtitude': [],
+ 'latitude': [],
+ 'address_map': [],
'zip': ['required']
})
diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py
index 2751ca7a..230707cb 100644
--- a/indoteknik_api/models/res_users.py
+++ b/indoteknik_api/models/res_users.py
@@ -59,6 +59,9 @@ class ResUsers(models.Model):
'rajaongkir_city_id': user.kecamatan_id.rajaongkir_id or 0,
'alamat_wajib_pajak': user.alamat_lengkap_text or None,
'alamat_bisnis': user.street or None,
+ 'longtitude': user.longtitude or None,
+ 'latitude': user.latitude or None,
+ 'address_map': user.address_map or None,
}
if user.state_id:
diff --git a/indoteknik_custom/models/crm_lead.py b/indoteknik_custom/models/crm_lead.py
index de2bdb12..078d9810 100755
--- a/indoteknik_custom/models/crm_lead.py
+++ b/indoteknik_custom/models/crm_lead.py
@@ -31,6 +31,8 @@ class CrmLead(models.Model):
if rec.email_from == 'api.noreply@altama.co.id' and rec.name.startswith('INDOTEKNIK|ODOO|'):
rec.user_id = 20 # User ID: Nabila Rahmawati
+ if not rec.user_id:
+ rec.user_id = 2 # User ID: Sales
return rec
@api.onchange('user_id')
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index f924174a..393fc562 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -68,6 +68,7 @@ class PurchaseOrder(models.Model):
], string='Printed?', copy=False, tracking=True)
date_done_picking = fields.Datetime(string='Date Done Picking', compute='get_date_done')
bills_dp_id = fields.Many2one('account.move', string='Bills DP')
+ bills_pelunasan_id = fields.Many2one('account.move', string='Bills Pelunasan')
grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total')
total_margin_match = fields.Float(string='Total Margin Match', compute='_compute_total_margin_match')
approve_by = fields.Many2one('res.users', string='Approve By')
@@ -89,6 +90,89 @@ class PurchaseOrder(models.Model):
else:
order.grand_total = order.amount_total
+ def create_bill_pelunasan(self):
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa bikin bill dp')
+
+ # Check for existing vendor bills with the same reference and partner
+ existing_bill = self.env['account.move'].search([
+ ('ref', '=', self.name),
+ ('partner_id', '=', self.partner_id.id),
+ ('move_type', '=', 'in_invoice'),
+ ('state', 'not in', ['cancel', 'posted'])
+ ], limit=1)
+
+ if existing_bill:
+ raise UserError(_('Duplicated vendor reference detected. You probably encoded twice the same vendor bill/credit note: %s') % existing_bill.name)
+
+ current_date = datetime.utcnow()
+ data_bills = {
+ 'partner_id': self.partner_id.id,
+ 'partner_shipping_id': self.partner_id.id,
+ 'ref': self.name,
+ 'invoice_date': current_date,
+ 'date': current_date,
+ 'move_type': 'in_invoice'
+ }
+
+ bills = self.env['account.move'].create([data_bills])
+
+ product_dp = self.env['product.product'].browse(229625)
+
+ data_line_bills = []
+
+ move_line = self.env['account.move.line'].search([
+ ('move_id', '=', self.bills_dp_id.id),
+ ('product_id', '=', product_dp.id),
+ ])
+
+ bills.message_post(
+ body=f"<div>"
+ f"<b>DP :</b><br>{move_line.price_unit}</div>",
+ subtype_id=self.env.ref("mail.mt_note").id
+ )
+
+ data_line_bills.append({
+ 'move_id': bills.id,
+ 'product_id': product_dp.id, # product down payment
+ 'name': '[IT.121456] Down Payment', # product down payment
+ 'account_id': 401, # Uang Muka persediaan barang dagang
+ # 'price_unit': move_line.price_unit,
+ 'quantity': -1,
+ 'product_uom_id': 1,
+ 'tax_ids': [(5, 0, 0)] + [(4, tax.id) for tax in product_dp.taxes_id],
+ })
+
+ for line in self.order_line:
+ if line.product_id:
+ data_line_bills.append({
+ 'move_id': bills.id,
+ 'product_id': line.product_id.id,
+ 'name': self.name + ": " + line.product_id.display_name,
+ 'account_id': 439, # Uang Muka persediaan barang dagang
+ 'quantity': line.product_qty,
+ # 'price_unit': line.price_subtotal,
+ 'product_uom_id': line.product_uom.id,
+ 'tax_ids': [(5, 0, 0)] + [(4, tax.id) for tax in line.taxes_id],
+ 'purchase_line_id': line.id,
+ 'purchase_order_id': line[0].order_id.id,
+ })
+
+ bills_line = self.env['account.move.line'].create(data_line_bills)
+
+ self.bills_pelunasan_id = bills.id
+
+ return {
+ 'name': _('Account Move'),
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.move',
+ 'target': 'current',
+ 'type': 'ir.actions.act_window',
+ 'domain': [('id', '=', bills.id)]
+ }
+
+
+
def create_bill_dp(self):
if not self.env.user.is_accounting:
raise UserError('Hanya Accounting yang bisa bikin bill dp')
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index c2b54dd9..017c7c96 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -171,6 +171,12 @@ class ResPartner(models.Model):
date_payment_terms_sales = fields.Datetime(string='Date Update Payment Terms')
user_payment_terms_purchase = fields.Many2one('res.users', string='Users Update Payment Terms')
date_payment_terms_purchase = fields.Datetime(string='Date Update Payment Terms')
+ longtitude = fields.Char(string='Longtitude')
+ latitude = fields.Char(string='Latitude')
+ address_map = fields.Char(string='Address Map')
+ company_type = fields.Selection(string='Company Type',
+ selection=[('person', 'Individual'), ('company', 'Company')],
+ compute='_compute_company_type', inverse='_write_company_type', tracking=3)
@api.model
def _default_payment_term(self):
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 3e609f15..06c76a82 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -27,7 +27,11 @@
<button name="delete_line" type="object" string="Delete " states="draft"/>
</button>
<button name="button_unlock" position="after">
- <button name="create_bill_dp" string="Create Bill DP" type="object" class="oe_highlight" attrs="{'invisible': [('state', 'not in', ('purchase', 'done'))]}"/>
+ <button name="create_bill_dp" string="Create Bill DP" type="object" class="oe_highlight" attrs="{'invisible': [('state', 'not in', ('purchase', 'done')), ('bills_pelunasan_id', '!=', False)]}"/>
+ </button>
+ <button name="button_unlock" position="after">
+ <button name="create_bill_pelunasan" string="Create Bill Pelunasan" type="object" class="oe_highlight" attrs="{'invisible': [('state', 'not in', ('purchase', 'done')), ('bills_pelunasan_id', '!=', False)]}"/>
+
</button>
<field name="date_order" position="before">
<field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
@@ -100,6 +104,7 @@
<field name="approval_edit_line"/>
<field name="logbook_bill_id"/>
<field name="bills_dp_id" readonly="1"/>
+ <field name="bills_pelunasan_id" readonly="1"/>
</field>
<field name="order_line" position="attributes">