Skip to content

Commit

Permalink
[REF] recurring_consignment_pos: Migration to V16:
Browse files Browse the repository at this point in the history
- no need to use anymore constrains to prevent sale to customer in Point of sale
- Add test
- add constrains to avoid to change a consignor setting, if a PoS session is opened because incorrect taxes configuration should be loaded and then generate bad account move.

[FIX] recurring_consignment:
- Fix bad lines in commission report, for account move lines that are generated by PoS
  • Loading branch information
legalsylvain authored and github-grap-bot committed Jul 25, 2024
1 parent 32c93fc commit 04e3d7f
Show file tree
Hide file tree
Showing 25 changed files with 465 additions and 192 deletions.
28 changes: 28 additions & 0 deletions recurring_consignment/demo/account_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<!-- oca-hooks: disable=xml-duplicate-record-id -->


<record id="account_receivable" model="account.account">
<field name="name">Demo Account Receivable</field>
<field name="code">411</field>
Expand Down Expand Up @@ -38,6 +41,27 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="company_id" ref="company" />
</record>

<record id="account_cash_suspense_account" model="account.account">
<field name="name">Cash Suspense Account</field>
<field name="code">5xx</field>
<field name="account_type">asset_current</field>
<field name="company_id" ref="company" />
</record>

<record id="account_expense_extra" model="account.account">
<field name="name">Extra Expense</field>
<field name="code">658</field>
<field name="account_type">expense</field>
<field name="company_id" ref="company" />
</record>

<record id="account_income_extra" model="account.account">
<field name="name">Extra Revenue</field>
<field name="code">758</field>
<field name="account_type">income</field>
<field name="company_id" ref="company" />
</record>

<record id="account_income_commission" model="account.account">
<field name="name">Commission Account</field>
<field name="code">706</field>
Expand All @@ -52,4 +76,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="company_id" ref="company" />
</record>

<record id="company" model="res.company">
<field name="account_default_pos_receivable_account_id" ref="account_receivable"/>
</record>

</odoo>
20 changes: 16 additions & 4 deletions recurring_consignment/demo/account_journal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,32 @@ Copyright (C) 2015 - 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>
<odoo noupdate="1">

<!-- oca-hooks: disable=xml-duplicate-record-id -->

<record id="account_journal_sale" model="account.journal">
<field name="name">Demo Sale Journal For Consignor</field>
<field name="name">Demo Sale Journal</field>
<field name="type">sale</field>
<field name="code">SJ-CONS</field>
<field name="code">SALE</field>
<field name="company_id" ref="company" />
</record>

<record id="account_journal_cash" model="account.journal">
<field name="name">Demo Cash Journal</field>
<field name="type">cash</field>
<field name="code">CASH</field>
<field name="company_id" ref="company" />
<field name="suspense_account_id" ref="account_cash_suspense_account" />
<field name="loss_account_id" ref="account_expense_extra" />
<field name="profit_account_id" ref="account_income_extra" />
</record>


<record id="account_journal_misc" model="account.journal">
<field name="name">Demo Misc Journal For Consignor</field>
<field name="type">general</field>
<field name="code">MC-CONS</field>
<field name="code">MISC</field>
<field name="company_id" ref="company" />
</record>

Expand Down
6 changes: 4 additions & 2 deletions recurring_consignment/demo/product_pricelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

<record id="sale_pricelist_10" model="product.pricelist">
<field name="name">My Pricelist (-10%)</field>
<field name="currency_id" ref="base.USD" />
<field name="company_id" ref="company"/>
<field name="currency_id" ref="base.EUR" />
</record>

<record id="sale_pricelist_item_10" model="product.pricelist.item">
Expand All @@ -21,7 +22,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

<record id="sale_pricelist_50" model="product.pricelist">
<field name="name">My Pricelist (-50%)</field>
<field name="currency_id" ref="base.USD" />
<field name="company_id" ref="company"/>
<field name="currency_id" ref="base.EUR" />
<field name="consignment_pricelist_id" ref="sale_pricelist_10"/>
</record>

Expand Down
55 changes: 31 additions & 24 deletions recurring_consignment/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 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-23 15:55+0000\n"
"PO-Revision-Date: 2024-06-23 15:55+0000\n"
"POT-Creation-Date: 2024-06-27 11:47+0000\n"
"PO-Revision-Date: 2024-06-27 11:47+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -29,8 +29,8 @@ msgid ""
"<span class=\"fa fa-lg fa-building-o\" role=\"img\" title=\"Values set here "
"are company-specific.\"/>"
msgstr ""
"<span class=\"fa fa-lg fa-building-o\" role=\"img\" title=\"Les valeurs définies ici sont"
" propres à l'entreprise.\"/>"
"<span class=\"fa fa-lg fa-building-o\" role=\"img\" title=\"Les valeurs "
"définies ici sont propres à l'entreprise.\"/>"

#. module: recurring_consignment
#. odoo-python
Expand Down Expand Up @@ -98,7 +98,9 @@ msgstr "Suffixe comptable"
msgid ""
"Account move Line that commissions the current line, if the related product "
"is a product related to consignor."
msgstr "Ligne comptable qui commissionne la ligne en cours, si le produit est un produit lié à un dépôt vendeur."
msgstr ""
"Ligne comptable qui commissionne la ligne en cours, si le produit est un "
"produit lié à un dépôt vendeur."

#. module: recurring_consignment
#: model_terms:ir.ui.view,arch_db:recurring_consignment.report_invoice_consignment
Expand All @@ -121,7 +123,8 @@ msgstr "Encaissé"
#: model:ir.model.fields,help:recurring_consignment.field_res_config_settings__recurring_consignment_account_prefix
#: model_terms:ir.ui.view,arch_db:recurring_consignment.res_config_settings_view_form
msgid "Code used as prefix to generate account code of the consignors."
msgstr "Code utilisé comme préfixe, pour générer le code comptable du dépôt vendeur."
msgstr ""
"Code utilisé comme préfixe, pour générer le code comptable du dépôt vendeur."

#. module: recurring_consignment
#: model_terms:ir.ui.view,arch_db:recurring_consignment.report_invoice_consignment
Expand Down Expand Up @@ -189,11 +192,6 @@ msgstr "Paramètres de configuration"
msgid "Confirm"
msgstr "Confirmer"

#. module: recurring_consignment
#: model:ir.ui.menu,name:recurring_consignment.menu_consignment
msgid "Consignment"
msgstr "Dépôt Vente"

#. module: recurring_consignment
#: model:ir.model.fields,field_description:recurring_consignment.field_res_partner__consignment_account_id
#: model:ir.model.fields,field_description:recurring_consignment.field_res_users__consignment_account_id
Expand Down Expand Up @@ -357,8 +355,8 @@ msgid ""
"Incorrect fiscal settings block the possibility to generate commission "
"invoices : Incorrect tax type on the tax %(tax_name)s"
msgstr ""
"Paramétrage fiscal incorrect qui empêche de générer les factures de commission: "
"Type de taxe incorrecte sur la taxe %(tax_name)s"
"Paramétrage fiscal incorrect qui empêche de générer les factures de "
"commission: Type de taxe incorrecte sur la taxe %(tax_name)s"

#. module: recurring_consignment
#. odoo-python
Expand All @@ -367,7 +365,7 @@ msgstr ""
msgid ""
"Incorrect fiscal settings block the possibility to generate commission "
"invoices: Too many taxes %(tax_names)s"
"Paramétrage fiscal incorrect qui empêche de générer les factures de commission: "
msgstr "Paramétrage fiscal incorrect qui empêche de générer les factures de commission: "
"Trop de taxe %(tax_names)s"

#. module: recurring_consignment
Expand Down Expand Up @@ -460,8 +458,9 @@ msgstr "Date maximum"
msgid ""
"Miscellaneous Journal, used to generate an entry that deducts the commission"
" from the amount to be paid out."
msgstr "Journal d'opérations diverses, utilisé pour générer les pièces comptables qui déduisent la commission"
" du montant à reverser."
msgstr ""
"Journal d'opérations diverses, utilisé pour générer les pièces comptables "
"qui déduisent la commission du montant à reverser."

#. module: recurring_consignment
#: model:ir.model.fields,field_description:recurring_consignment.field_invoice_commission_wizard_line__move_line_qty
Expand Down Expand Up @@ -531,7 +530,7 @@ msgstr "Liste de prix"
#. module: recurring_consignment
#: model:ir.model,name:recurring_consignment.model_product_pricelist_item
msgid "Pricelist Rule"
msgstr "Élément de la liste de prix"
msgstr "Règle des listes des prix"

#. module: recurring_consignment
#: model:ir.model.fields,field_description:recurring_consignment.field_product_pricelist__consignment_pricelist_id
Expand Down Expand Up @@ -560,7 +559,8 @@ msgstr "Variante de produit"
msgid ""
"Product that will be used to generate consignment invoices to consignors."
msgstr ""
"Produit qui sera utilisé pour générer des factures de dépôt vente aux dépôt vendeurs."
"Produit qui sera utilisé pour générer des factures de dépôt vente aux dépôt "
"vendeurs."

#. module: recurring_consignment
#: model_terms:ir.ui.view,arch_db:recurring_consignment.view_consignor_create_wizard_form
Expand All @@ -574,7 +574,9 @@ msgstr "Qté"

#. module: recurring_consignment
#: model_terms:ir.ui.view,arch_db:recurring_consignment.res_config_settings_view_form
msgid "Recurring Consigment"
#: model_terms:ir.ui.view,arch_db:recurring_consignment.view_account_move_form
#: model:ir.ui.menu,name:recurring_consignment.menu_consignment
msgid "Recurring Consignment"
msgstr "Dépôt vente"

#. module: recurring_consignment
Expand Down Expand Up @@ -602,10 +604,10 @@ msgid ""
"If you dont find the correct Fiscal Classification, Please create a new one "
"or ask to your account manager if you don't have the access right."
msgstr ""
"Indiquer la combinaison de taxes pour ce produit. Ce champ est requis. Si "
"Indiquez la combinaison de taxes pour ce produit. Ce champ est requis. Si "
"vous ne trouvez pas la catégorie fiscale que vous cherchez, vous pouvez en "
"créer une autre, ou demander à votre responsable comptable, si vous n'avez "
"pas les droits d'accès."
"créer une nouvelle, ou demander à votre responsable comptable de le faire si"
" vous n'avez pas les droits d'accès."

#. module: recurring_consignment
#: model:ir.model.fields,field_description:recurring_consignment.field_consignor_create_wizard__is_vat_subject
Expand Down Expand Up @@ -639,8 +641,8 @@ msgid ""
"The product '{product_name} has inconsistent consignor ({consignor_name}) "
"and fiscal classification ({classification_name})."
msgstr ""
"Le produit '{product_name}' a un dépôt vente inconsistent ({consignor_name}) "
"avec la catégorie fiscale ({classification_name})."
"Le produit '{product_name}' a un dépôt vente inconsistent ({consignor_name})"
" avec la catégorie fiscale ({classification_name})."

#. module: recurring_consignment
#. odoo-python
Expand Down Expand Up @@ -711,6 +713,11 @@ msgstr "TVA 10,0%"
msgid "VAT 20,0%"
msgstr "TVA 20,0%"

#. module: recurring_consignment
#: model_terms:ir.ui.view,arch_db:recurring_consignment.view_account_move_form
msgid "View commissionned invoiced lines"
msgstr "Voir les lignes de facture commissionnées"

#. module: recurring_consignment
#: model:ir.model.fields,field_description:recurring_consignment.field_invoice_commission_wizard_line__wizard_id
msgid "Wizard"
Expand Down
2 changes: 1 addition & 1 deletion recurring_consignment/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _get_commission_information_product_detail_grouped(self):
# Get related invoice lines
com_invoice_lines = self.mapped(
"invoice_line_ids.consignment_invoice_line_ids"
).filtered(lambda x: x.display_type == "product")
).filtered(lambda x: x.display_type == "product" and x.product_id)

for com_invoice_line in com_invoice_lines:
key = (
Expand Down
16 changes: 2 additions & 14 deletions recurring_consignment/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
from odoo.exceptions import Warning as UserError
from odoo.exceptions import UserError


class ResPartner(models.Model):
Expand Down Expand Up @@ -35,7 +35,7 @@ def _check_is_consignor_consignment_account_id(self):
if partner.is_consignor:
if not partner.consignment_account_id:
raise UserError(
_("A Consignor must have a 'Consignment Account'" " defined.")
_("A Consignor must have a 'Consignment Account' defined.")
)
else:
if (
Expand All @@ -48,15 +48,3 @@ def _check_is_consignor_consignment_account_id(self):
" Commission' neither 'Consignment Account' defined."
)
)

# TODO prevent check and uncheck. (only via wizard is possible)
# # Overload Section
# def write(self, vals):
# if not vals.get("is_consignor", True) and any(self.mapped("is_consignor")):
# raise UserError(
# _(
# "You can not unset consignor setting on partner.\n"
# " Please create a new one if you want to do so."
# )
# )
# return super().write(vals)
6 changes: 3 additions & 3 deletions recurring_consignment/tests/test_make_commissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@tagged("post_install", "-at_install")
class TestCreateConsignors(TransactionCase):
class TestMakeCommissions(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -73,13 +73,13 @@ def test_30_commission_workflow(self):
self.assertEqual(
len(commission_invoice.invoice_line_ids),
1,
"Two commission lines should be generated",
"One commission line should be generated",
)
self.assertEqual(
len(lines_20), 1, "One 20% commission line should be generated"
)

# Check line #2 details (Tax Excl)
# Check line details (Tax Excl)
line_20 = lines_20[0]
self.assertEqual(line_20.quantity, 1, "Incorrect Commission Quantity.")
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion recurring_consignment/views/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<odoo>

<menuitem id="menu_consignment"
name="Consignment"
name="Recurring Consignment"
parent="account.menu_finance_payables" sequence="300"
groups="recurring_consignment.group_consignment_user"/>

Expand Down
2 changes: 1 addition & 1 deletion recurring_consignment/views/view_res_config_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<field name="arch" type="xml">
<xpath expr="//div[@id='print_vendor_checks_setting_container']" position="after">

<h2 groups="recurring_consignment.group_consignment_manager">Recurring Consigment</h2>
<h2 groups="recurring_consignment.group_consignment_manager">Recurring Consignment</h2>
<div class="row mt16 o_settings_container" id="recurring_consignment"
groups="recurring_consignment.group_consignment_manager">

Expand Down
12 changes: 8 additions & 4 deletions recurring_consignment_pos/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
"website": "https://github.com/grap/grap-odoo-business",
"license": "AGPL-3",
"depends": [
"recurring_consignment",
# Odoo
"point_of_sale",
# GRAP
"recurring_consignment",
],
"data": [
"views/view_account_invoice.xml",
"views/templates.xml",
"data": ["views/view_account_move.xml"],
"demo": [
"demo/pos_payment_method.xml",
"demo/pos_config.xml",
"demo/product_product.xml",
],
"installable": True,
"auto_install": True,
Expand Down
19 changes: 19 additions & 0 deletions recurring_consignment_pos/demo/pos_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2015 - 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="pos_config" model="pos.config">
<field name="name">Pos Config</field>
<field name="company_id" ref="recurring_consignment.company" />
<field name="journal_id" ref="recurring_consignment.account_journal_sale" />
<field name="picking_type_id" model="stock.picking.type" search="[('company_id', '=', ref('recurring_consignment.company')), ('code', '=', 'outgoing'), ('sequence_code', '=', 'POS')]" />
<field name="invoice_journal_id" ref="recurring_consignment.account_journal_sale" />
<field name="payment_method_ids" eval="[(4, ref('recurring_consignment_pos.payment_method_cash'))]" />
<field name="available_pricelist_ids" eval="[(4, ref('recurring_consignment.sale_pricelist_10'))]" />
</record>

</odoo>
Loading

0 comments on commit 04e3d7f

Please sign in to comment.