Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] commission invoices #93

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions joint_buying_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"wizards/view_joint_buying_invoice_commission_wizard.xml",
"views/view_res_config_settings.xml",
"views/view_joint_buying_purchase_order_grouped.xml",
"views/view_joint_buying_transport_request.xml",
],
"installable": True,
"auto_install": True,
Expand Down
46 changes: 34 additions & 12 deletions joint_buying_account/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-15 14:08+0000\n"
"PO-Revision-Date: 2024-03-15 14:08+0000\n"
"POT-Creation-Date: 2024-04-05 16:01+0000\n"
"PO-Revision-Date: 2024-04-05 16:01+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"Plural-Forms: \n"

#. module: joint_buying_account
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:179
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:246
#, python-format
msgid "\n"
"- Non-commissioned sale: %s ; %.2f €"
Expand All @@ -30,11 +30,13 @@ msgstr "Annuler"

#. module: joint_buying_account
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_purchase_order_grouped__invoice_id
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_transport_request__invoice_id
msgid "Commission Invoice"
msgstr "Facture de commission"

#. module: joint_buying_account
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_purchase_order_grouped__invoice_line_id
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_transport_request__invoice_line_id
msgid "Commission Invoice Line"
msgstr "Ligne de facture de commission"

Expand All @@ -50,7 +52,7 @@ msgid "Commission VAT 20% Excl"
msgstr "Commission 20% HT"

#. module: joint_buying_account
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:165
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:232
#, python-format
msgid "Commission on %s deposited on %s\n"
"- Ordered Amount : %.2f €\n"
Expand All @@ -61,6 +63,16 @@ msgstr "Commission sur %s déposé le %s\n"
"- %d Clients: %s\n"
"- Taux : %.2f %%"

#. module: joint_buying_account
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:258
#, python-format
msgid "Commission on transport Request from %s to %s available on %s\n"
"- Amount : %.2f €\n"
"- Rate : %.2f %%"
msgstr "Commission sur demande de transport de %s à %s disponible le %s\n"
"- Montant : %.2f €\n"
"- Taux : %.2f %%"

#. module: joint_buying_account
#: model:ir.model,name:joint_buying_account.model_res_company
msgid "Companies"
Expand Down Expand Up @@ -105,6 +117,11 @@ msgstr "Nom affiché"
msgid "Ecureuil Garni 150gr LAIT (VAT INCL)"
msgstr ""

#. module: joint_buying_account
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_invoice_commission_wizard_line__grouped_order_qty
msgid "Grouped Order Quantity"
msgstr "Quantité de commandes groupées"

#. module: joint_buying_account
#: model:product.product,name:joint_buying_account.product_ELD_hibou
#: model:product.template,name:joint_buying_account.product_ELD_hibou_product_template
Expand All @@ -118,13 +135,13 @@ msgid "ID"
msgstr ""

#. module: joint_buying_account
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:124
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:190
#, python-format
msgid "Incorrect fiscal settings block the possibility to generate commission invoices : Incorrect tax type on the tax %s"
msgstr "Le paramétrage fiscal incorrect empêche de générer des factures de commission : type de taxe incorrect sur la taxe %s"

#. module: joint_buying_account
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:114
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:180
#, python-format
msgid "Incorrect fiscal settings block the possibility to generate commission invoices : Too many taxes %s"
msgstr "Le paramétrage fiscal incorrect empêche de générer des factures de commissions : Trop de taxes %s"
Expand All @@ -150,6 +167,11 @@ msgstr "Commande groupée"
msgid "Joint Buying Invoice Commission Wizard"
msgstr "Assistant de commission de commande groupé"

#. module: joint_buying_account
#: model:ir.model,name:joint_buying_account.model_joint_buying_transport_request
msgid "Joint Buying Transport Request"
msgstr "Demande de transport"

#. module: joint_buying_account
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_invoice_commission_wizard____last_update
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_invoice_commission_wizard_line____last_update
Expand Down Expand Up @@ -199,11 +221,6 @@ msgstr "Aucune commande groupée à facturer pour les fournisseurs sélectionné
msgid "Product"
msgstr "Article"

#. module: joint_buying_account
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_invoice_commission_wizard_line__grouped_order_qty
msgid "Quantity"
msgstr "Quantité"

#. module: joint_buying_account
#: model_terms:ir.ui.view,arch_db:joint_buying_account.view_res_config_settings_form
msgid "Set the product used to make commission invoices."
Expand All @@ -229,6 +246,11 @@ msgstr "Fournisseurs"
msgid "The commission will be computed for the grouped order deposited by the suppliers until this date included."
msgstr "La commission sera calculée pour les commandes groupées déposés par les fournisseurs jusqu'à cette date inclue."

#. module: joint_buying_account
#: model:ir.model.fields,field_description:joint_buying_account.field_joint_buying_invoice_commission_wizard_line__transport_request_qty
msgid "Transport Request Quantity"
msgstr "Quantité de demandes de transport"

#. module: joint_buying_account
#: model:product.product,uom_name:joint_buying_account.product_ELD_ecureuil
#: model:product.product,uom_name:joint_buying_account.product_ELD_hibou
Expand All @@ -245,7 +267,7 @@ msgid "Wizard"
msgstr "Assistant"

#. module: joint_buying_account
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:196
#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:290
#, python-format
msgid "You should define a local partner for the supplier %s."
msgstr "Vous devez définir un partenaire local pour le fournisseur %s."
Expand Down
1 change: 1 addition & 0 deletions joint_buying_account/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from . import res_config_settings
from . import product_product
from . import joint_buying_purchase_order_grouped
from . import joint_buying_transport_request
21 changes: 21 additions & 0 deletions joint_buying_account/models/joint_buying_transport_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2024-Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class JointBuyingTransportRequest(models.Model):
_inherit = "joint.buying.transport.request"

invoice_line_id = fields.Many2one(
string="Commission Invoice Line",
comodel_name="account.invoice.line",
readonly=True,
)

invoice_id = fields.Many2one(
string="Commission Invoice",
comodel_name="account.invoice",
related="invoice_line_id.invoice_id",
)
18 changes: 13 additions & 5 deletions joint_buying_account/tests/test_commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,35 @@ def setUp(self):
super().setUp()
self.company_LOG = self.env.ref("joint_buying_base.company_LOG")
self.benoit_ronzon = self.env.ref("joint_buying_base.supplier_benoit_ronzon")
self.CommissionWizard = self.env[
self.CommissionWizardRonzon = self.env[
"joint.buying.invoice.commission.wizard"
].with_context(active_ids=self.benoit_ronzon.ids)
self.AccountInvoice = self.env["account.invoice"]
self.grouped_orders = self.benoit_ronzon.joint_buying_grouped_order_ids
self.env.user.company_id = self.company_LOG

def test_01_create_commission(self):
def test_01_create_commission_from_grouped_orders(self):
# Wizard in a date BEFORE the delivery of grouped orders, should fail
day_before_deposit = min(
self.grouped_orders.mapped("deposit_date")
) + timedelta(days=-1)
wizard = self.CommissionWizard.create({"max_deposit_date": day_before_deposit})
wizard = self.CommissionWizardRonzon.create(
{"max_deposit_date": day_before_deposit}
)
self.assertEqual(len(wizard.line_ids), 1)
self.assertEqual(wizard.line_ids[0].grouped_order_qty, 0)
self.assertEqual(wizard.line_ids[0].transport_request_qty, 0)
with self.assertRaises(UserError):
wizard.invoice_commission()

# Wizard in a date AFTER the delivery of grouped orders, should success
day_after_deposit = max(self.grouped_orders.mapped("deposit_date"))
wizard = self.CommissionWizard.create({"max_deposit_date": day_after_deposit})
wizard = self.CommissionWizardRonzon.create(
{"max_deposit_date": day_after_deposit}
)
self.assertEqual(len(wizard.line_ids), 1)
self.assertEqual(wizard.line_ids[0].grouped_order_qty, len(self.grouped_orders))
self.assertEqual(wizard.line_ids[0].transport_request_qty, 0)
result = wizard.invoice_commission()

# Check invoice content
Expand All @@ -47,6 +53,8 @@ def test_01_create_commission(self):
)

# Try to re create invoices, should fail
wizard = self.CommissionWizard.create({"max_deposit_date": day_after_deposit})
wizard = self.CommissionWizardRonzon.create(
{"max_deposit_date": day_after_deposit}
)
with self.assertRaises(UserError):
wizard.invoice_commission()
19 changes: 19 additions & 0 deletions joint_buying_account/views/view_joint_buying_transport_request.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2024 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="view_joint_buying_transport_request_form" model="ir.ui.view">
<field name="model">joint.buying.transport.request</field>
<field name="inherit_id" ref="joint_buying_base.view_joint_buying_transport_request_form" />
<field name="arch" type="xml">
<field name="amount_untaxed" position="after">
<field name="invoice_id"/>
</field>
</field>
</record>

</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def invoice_commission(self):
self._check_values()
invoices = self.env["account.invoice"]

for wizard_line in self.line_ids.filtered(lambda x: x.grouped_order_qty):
for wizard_line in self.line_ids.filtered(
lambda x: x.grouped_order_qty or x.transport_request_qty
):
invoice = wizard_line._create_invoice()
invoices |= invoice

Expand Down
Loading
Loading