mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: improvement create downpayment invoice and reconcile
This commit is contained in:
@@ -24,3 +24,6 @@ class PmsAccountInvoiceInfo(Datamodel):
|
||||
isDownPaymentInvoice = fields.Boolean(required=False, allow_none=True)
|
||||
isSimplifiedInvoice = fields.Boolean(required=False, allow_none=True)
|
||||
reversedEntryId = fields.Integer(required=False, allow_none=True)
|
||||
# REVIEW: originDownPaymentId Only input field to service to
|
||||
# create downpayment invoices from payments
|
||||
originDownPaymentId = fields.Integer(required=False, allow_none=True)
|
||||
|
||||
@@ -643,6 +643,7 @@ class PmsFolioService(Component):
|
||||
invoices = folios_to_invoice._create_invoices(
|
||||
lines_to_invoice=lines_to_invoice_dict,
|
||||
partner_invoice_id=invoice_info.partnerId,
|
||||
final=True, # To force take into account down payments
|
||||
)
|
||||
for item in invoice_info.saleLines:
|
||||
if item.id in invoices.invoice_line_ids.mapped("folio_line_ids.id"):
|
||||
|
||||
@@ -131,6 +131,28 @@ class PmsInvoiceService(Component):
|
||||
invoice.action_post()
|
||||
return invoice
|
||||
|
||||
@restapi.method(
|
||||
[
|
||||
(
|
||||
[
|
||||
"/",
|
||||
],
|
||||
"POST",
|
||||
)
|
||||
],
|
||||
input_param=Datamodel("pms.invoice.info"),
|
||||
auth="jwt_api_pms",
|
||||
)
|
||||
def create_invoice(self, pms_invoice_info):
|
||||
if pms_invoice_info.originDownPaymentId:
|
||||
if not pms_invoice_info.partnerId:
|
||||
raise UserError(_("For manual invoice, partner is required"))
|
||||
payment = self.env["account.payment"].browse(pms_invoice_info.paymentId)
|
||||
self.env["account.payment"]._create_downpayment_invoice(
|
||||
payment=payment,
|
||||
partner_id=pms_invoice_info.partnerId,
|
||||
)
|
||||
|
||||
@restapi.method(
|
||||
[
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user