Skip to content

Commit

Permalink
fix: add is_subcontracted check for additional validation/submit/canc…
Browse files Browse the repository at this point in the history
…el code
  • Loading branch information
HKuz committed Aug 30, 2023
1 parent 7bbe3df commit 8182dac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions inventory_tools/inventory_tools/overrides/purchase_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ def validate_with_previous_doc(self):
)

def validate(self):
if self.is_work_order_subcontracting_enabled():
if self.is_work_order_subcontracting_enabled() and self.is_subcontracted:
if not self.supplier_warehouse:
self.supplier_warehouse = fetch_supplier_warehouse(self.company, self.supplier)
self.validate_subcontracting_to_pay_qty()
return super().validate()

def on_submit(self):
if self.is_work_order_subcontracting_enabled():
if self.is_work_order_subcontracting_enabled() and self.is_subcontracted:
self.on_submit_save_se_paid_qty()
return super().on_submit()

def on_cancel(self):
if self.is_work_order_subcontracting_enabled():
if self.is_work_order_subcontracting_enabled() and self.is_subcontracted:
self.on_cancel_revert_se_paid_qty()
return super().on_cancel()

Expand Down
4 changes: 2 additions & 2 deletions inventory_tools/inventory_tools/overrides/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def validate_warehouse(self):
validate_warehouse_company(w, self.company)

def validate(self):
if self.is_work_order_subcontracting_enabled():
if self.is_work_order_subcontracting_enabled() and self.is_subcontracted:
self.validate_subcontracting_fg_qty()
for row in self.subcontracting:
# TODO: set work order supplier to empty string in on_cancel
Expand All @@ -90,7 +90,7 @@ def is_work_order_subcontracting_enabled(self):

def validate_subcontracting_fg_qty(self):
sub_wo = self.get("subcontracting")
if self.is_subcontracted and sub_wo:
if sub_wo:
items_fg_qty = sum(item.get("fg_item_qty") or 0 for item in self.get("items"))
subc_fg_qty = sum(row.get("fg_item_qty") or 0 for row in sub_wo)
# Check that the item finished good qty and the subcontracting qty are within the item's stock_qty field's precision number of decimals
Expand Down

0 comments on commit 8182dac

Please sign in to comment.