summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-10-02 15:31:02 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-10-02 15:31:02 +0700
commit8b63d79efe0137ce6af535847f33868e73ce8d3c (patch)
tree43d1e5f0efb1bb5e7a3a7c50aa66417879fc5c44
parent0e9e9e47e92d251ee1ce6268208737c0b7aeff30 (diff)
add validation data realshippingaddress
-rwxr-xr-xindoteknik_custom/models/sale_order.py19
-rw-r--r--indoteknik_custom/views/res_partner.xml9
2 files changed, 26 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 2b20a533..f8127d8c 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -419,6 +419,22 @@ class SaleOrder(models.Model):
for line in order.order_line:
total += line.vendor_subtotal
order.purchase_total = total
+
+ def check_data_real_delivery_address(self):
+ real_delivery_address = self.real_shipping_id
+
+ if not real_delivery_address.state_id:
+ raise UserError('State Real Delivery Address harus diisi')
+ if not real_delivery_address.zip:
+ raise UserError('Zip code Real Delivery Address harus diisi')
+ if not real_delivery_address.mobile:
+ raise UserError('Mobile Real Delivery Address harus diisi')
+ if not real_delivery_address.phone:
+ raise UserError('Phone Real Delivery Address harus diisi')
+ if not real_delivery_address.kecamatan_id:
+ raise UserError('Kecamatan Real Delivery Address harus diisi')
+ if not real_delivery_address.kelurahan_id:
+ raise UserError('Kelurahan Real Delivery Address harus diisi')
def generate_payment_link_midtrans_sales_order(self):
# midtrans_url = 'https://app.sandbox.midtrans.com/snap/v1/transactions' # dev - sandbox
@@ -565,8 +581,6 @@ class SaleOrder(models.Model):
raise UserError('Phone Real Delivery Address harus diisi')
if not real_delivery_address.kecamatan_id:
raise UserError('Kecamatan Real Delivery Address harus diisi')
- if not real_delivery_address.kelurahan_id:
- raise UserError('Kelurahan Real Delivery Address harus diisi')
@api.onchange('partner_id')
def onchange_partner_contact(self):
@@ -791,6 +805,7 @@ class SaleOrder(models.Model):
def action_confirm(self):
for order in self:
+ order.check_data_real_delivery_address()
order.sale_order_check_approve()
order._validate_order()
order.order_line.validate_line()
diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml
index d77e09b8..6d02a86b 100644
--- a/indoteknik_custom/views/res_partner.xml
+++ b/indoteknik_custom/views/res_partner.xml
@@ -29,6 +29,15 @@
<field name="nama_wajib_pajak" position="attributes">
<attribute name="required">1</attribute>
</field>
+ <field name="kota_id" position="attributes">
+ <attribute name="required">0</attribute>
+ </field>
+ <field name="kecamatan_id" position="attributes">
+ <attribute name="required">0</attribute>
+ </field>
+ <field name="kelurahan_id" position="attributes">
+ <attribute name="required">0</attribute>
+ </field>
<field name="npwp" position="attributes">
<attribute name="required">1</attribute>
</field>