Skip to content

Commit

Permalink
[FIX] lcc_lokavaluto_app_connection: correction on sale_order creati
Browse files Browse the repository at this point in the history
on order management from credit_requests
  • Loading branch information
Stéphan Sainléger committed May 23, 2024
1 parent 7dd5723 commit e3c2648
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lcc_comchain_base/migrations/12.0.3.0.0/post-migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def migrate(env, version):
"partner_id": partner_id.id,
"wallet_id": wallet.id,
"invoice_id": invoice[0],
"create_order": False,
"no_order": True,
}
)
env["credit.request"].create(values)
Expand Down
2 changes: 1 addition & 1 deletion lcc_credit_requests_from_contracts/models/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def _prepare_credit_request_values(self, invoice):
"partner_id": invoice.partner_id.id,
"wallet_id": self.wallet_id.id,
"invoice_id": invoice.id,
"create_order": False,
"no_order": True,
}
return values

Expand Down
2 changes: 1 addition & 1 deletion lcc_cyclos_base/migrations/12.0.3.0.0/post-migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def migrate(env, version):
"partner_id": partner_id.id,
"wallet_id": wallet.id,
"invoice_id": invoice[0],
"create_order": False,
"no_order": True,
}
env["credit.request"].create(values)

Expand Down
13 changes: 8 additions & 5 deletions lcc_lokavaluto_app_connection/models/credit_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ def create(self, vals):
raise UserError("Credit resquest can't be created with a null amount.")

res = super(CreditRequest, self).create(vals)

if vals.get("no_order", False):
return res

# Create Sale Order to get credit request payment
if vals.get("create_order", False):
new_order = res.partner_id.create_numeric_lcc_order(
res.wallet_id, res.amount
)
res.order_id = new_order.id
new_order = res.partner_id.create_numeric_lcc_order(
res.wallet_id, res.amount
)
res.order_id = new_order.id
return res

@api.multi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def create_credit_request(self):
values = {
"wallet_id": self.wallet_id.id,
"amount": self.amount,
"create_order": True,
}
credit_request_id = self.env["credit.request"].create(values)
view = self.env.ref("lcc_lokavaluto_app_connection.credit_request_view_form")
Expand Down

0 comments on commit e3c2648

Please sign in to comment.