[IMP] account_payment_order: Add hook method for finding previous payment orders

This commit is contained in:
AmmarOfficewalaSerpentCS
2021-07-06 14:22:50 +05:30
parent e48e59d2ac
commit 1f4e943129
4 changed files with 16 additions and 5 deletions

View File

@@ -110,6 +110,10 @@ Contributors
* Carlos Dauden * Carlos Dauden
* Carlos Roca * Carlos Roca
* `Open Source Integrators <https://www.opensourceintegrators.com>`_:
* Ammar Officewala <aofficewala@opensourceintegrators.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~

View File

@@ -49,6 +49,9 @@ class AccountMove(models.Model):
# in account_payment_order.py # in account_payment_order.py
return vals return vals
def get_account_payment_domain(self, payment_mode):
return [("payment_mode_id", "=", payment_mode.id), ("state", "=", "draft")]
def create_account_payment_line(self): def create_account_payment_line(self):
apoo = self.env["account.payment.order"] apoo = self.env["account.payment.order"]
result_payorder_ids = [] result_payorder_ids = []
@@ -81,11 +84,7 @@ class AccountMove(models.Model):
raise UserError(_("No Payment Mode on invoice %s") % move.name) raise UserError(_("No Payment Mode on invoice %s") % move.name)
for payment_mode in payment_modes: for payment_mode in payment_modes:
payorder = apoo.search( payorder = apoo.search(
[ self.get_account_payment_domain(payment_mode), limit=1
("payment_mode_id", "=", payment_mode.id),
("state", "=", "draft"),
],
limit=1,
) )
new_payorder = False new_payorder = False
if not payorder: if not payorder:

View File

@@ -23,3 +23,7 @@
* Pedro M. Baeza * Pedro M. Baeza
* Carlos Dauden * Carlos Dauden
* Carlos Roca * Carlos Roca
* `Open Source Integrators <https://www.opensourceintegrators.com>`_:
* Ammar Officewala <aofficewala@opensourceintegrators.com>

View File

@@ -456,6 +456,10 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Carlos Roca</li> <li>Carlos Roca</li>
</ul> </ul>
</li> </li>
<li><a class="reference external" href="https://www.opensourceintegrators.com">Open Source Integrators</a>:<ul>
<li>Ammar Officewala &lt;<a class="reference external" href="mailto:aofficewala&#64;opensourceintegrators.com">aofficewala&#64;opensourceintegrators.com</a>&gt;</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">