Skip to content
Extraits de code Groupes Projets
Valider ba89b081 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[fix] error wizard refund + add same date_due as quarter

parent b159a4d7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -38,7 +38,7 @@ class ScopBordereauRefundWizard(models.TransientModel):
# ------------------------------------------------------
@api.constrains("date_refund")
def _check_date_refund(self):
last_date = max(self.bordereau_id.invoice_ids.mapped("date_invoice"))
last_date = max(self.bordereau_id.invoice_ids.mapped("invoice_date"))
if self.date_refund > fields.Date.today() or self.date_refund < last_date:
raise ValidationError(
_(
......@@ -168,7 +168,6 @@ class ScopBordereauRefundWizard(models.TransientModel):
],
self.env.ref("cgscop_partner.riga_14399").id: [
product_ur,
self.env.company.contribution_ur_or_fede_journal_id,
journal_ur,
partner_id.property_account_receivable_id,
],
......@@ -176,34 +175,36 @@ class ScopBordereauRefundWizard(models.TransientModel):
product = cotiz_type.get(int(self.type_cotiz))[0]
for quarter_id in self.quarter_ids:
refund = self.env["account.invoice"].create(
date_due = self.bordereau_id.invoice_ids.filtered(
lambda i: i.cotiz_quarter == str(quarter_id.quarter) and i.move_type == "out_invoice")[0].invoice_date_due
refund = self.env["account.move"].create(
{
"partner_id": partner_id.id,
"journal_id": cotiz_type.get(int(self.type_cotiz))[1].id,
"type": "out_refund",
"date_invoice": self.date_refund,
"move_type": "out_refund",
"invoice_date": self.date_refund,
"date": self.date_refund,
"state": "draft",
"number": False,
"origin": bordereau_id.name,
"name": self.comment,
"ref": self.comment,
"bordereau_id": bordereau_id.id,
"is_contribution": True,
"year": bordereau_id.year,
"cotiz_quarter": quarter_id.quarter,
"cotiz_quarter": str(quarter_id.quarter),
"liasse_fiscale_id": bordereau_id.liasse_fiscale_id.id,
"type_contribution_id": self.type_cotiz,
"payment_mode_id": bordereau_id.payment_mode_id.id,
"date_due": self.date_refund,
"invoice_date_due": date_due,
}
)
self.env["account.invoice.line"].create(
self.env["account.move.line"].create(
{
"name": self.comment,
"invoice_id": refund.id,
"move_id": refund.id,
"product_id": product.id,
"account_id": product.property_account_income_id.id,
"quantity": 1,
"price_unit": self.amount_refund,
"price_subtotal": self.amount_refund,
}
)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter