diff --git a/__manifest__.py b/__manifest__.py index 01ae5bf26ec014c0cbb8e02df7b12d2f423a3c7e..7802a49fea5d62def58f14ec4820c637727b190e 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -3,7 +3,7 @@ "summary": "Gestion de la facturation sur les opérations", "author": "Le Filament, Odoo SA", "website": "https://le-filament.com", - "version": "16.0.3.0.0", + "version": "16.0.4.0.0", "license": "AGPL-3", "depends": [ "account_banking_sepa_direct_debit", @@ -34,6 +34,7 @@ "views/account_banking_mandate_views.xml", "views/account_move_views.xml", "views/account_payment_order_views.xml", + "views/account_payment_term_views.xml", "views/res_bank_views.xml", "views/res_company_views.xml", "views/res_config_settings_views.xml", diff --git a/migrations/16.0.4.0.0/post-migration.py b/migrations/16.0.4.0.0/post-migration.py new file mode 100644 index 0000000000000000000000000000000000000000..0314892736795a80f1264103fdf888a53ca0f992 --- /dev/null +++ b/migrations/16.0.4.0.0/post-migration.py @@ -0,0 +1,13 @@ +# Copyright 2023- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + # Initialize account.payment.term days_offset field + all_terms = env["account.payment.term"].search([]) + all_terms.filtered(lambda term: not term.company_id).write({"active": False}) + for term in all_terms: + balance_line = term.line_ids.filtered(lambda line: line.value == "balance")[0] + term.write({"days_offset": balance_line.months * 30 + balance_line.days}) diff --git a/models/__init__.py b/models/__init__.py index d4805cc89f285d2ba21f3f1590dd0424bff25cd8..00d5171cc50023f97d2d44557323f401c45a9077 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -1,13 +1,14 @@ from . import account_move from . import account_move_line +from . import account_payment_order +from . import account_payment_term +from . import acc_accise_category from . import acc_counter_period from . import acc_operation +from . import acc_operation_role from . import acc_price_conf from . import base_document_layout +from . import ir_actions_report from . import res_company from . import res_config_settings -from . import ir_actions_report from . import res_partner -from . import acc_operation_role -from . import acc_accise_category -from . import account_payment_order diff --git a/models/account_payment_order.py b/models/account_payment_order.py index 81d4a19ad214902e5cafdf6754fd3a2b749f792e..09a8a2d8e0a006f3d867b4c326614a7d2db92367 100644 --- a/models/account_payment_order.py +++ b/models/account_payment_order.py @@ -12,3 +12,6 @@ class AccountPaymentOrder(models.Model): Re-generate the account payments. """ return super(AccountPaymentOrder, self.with_user(SUPERUSER_ID)).draft2open() + + def action_cancel(self): + return super(AccountPaymentOrder, self.with_user(SUPERUSER_ID)).action_cancel() diff --git a/models/account_payment_term.py b/models/account_payment_term.py new file mode 100644 index 0000000000000000000000000000000000000000..ffa4c6ddc4d9b88e36d78cbaa875be41354a9f60 --- /dev/null +++ b/models/account_payment_term.py @@ -0,0 +1,41 @@ +from dateutil.relativedelta import relativedelta + +from odoo import fields, models + + +class AccountPaymentTerm(models.Model): + _inherit = "account.payment.term" + + # set default company instead of None + company_id = fields.Many2one("res.company", default=lambda self: self.env.company) + + days_offset = fields.Integer("Délai de paiement (jours)") + + def _compute_terms( + self, + date_ref, + currency, + company, + tax_amount, + tax_amount_currency, + sign, + untaxed_amount, + untaxed_amount_currency, + cash_rounding=None, + ): + """ + Override default function in order to only calculate offset based on days_offset + """ + return [ + { + "date": fields.Date.from_string(date_ref) + + relativedelta(days=self.days_offset), + "has_discount": 0.0, + "discount_date": None, + "discount_amount_currency": 0.0, + "discount_balance": 0.0, + "discount_percentage": 0.0, + "foreign_amount": untaxed_amount_currency + tax_amount_currency, + "company_amount": untaxed_amount + tax_amount, + } + ] diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 35eabf3c4e4a8216ec3fc2e787eb046ff04f23da..e707edcbbd062087be234f082d61e3b3c79df751 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -12,3 +12,5 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink "access_acc_account_journal_group_operation_admin_invoice","account_journal group_operation_admin_invoice","account.model_account_journal","oacc_account.group_operation_admin_invoice",1,0,0,0 "access_acc_account_partial_reconcile_group_operation_admin_invoice","account_partial_reconcile group_operation_admin_invoice","account.model_account_partial_reconcile","oacc_account.group_operation_admin_invoice",1,0,0,0 "base.access_res_bank_group_partner_manager","Full access on res.bank to Account Payment group","base.model_res_bank","account_payment_order.group_account_payment",1,0,0,0 +"access_acc_account_payment_term_group_operation_admin_invoice","account_payment_term group_operation_admin_invoice","account.model_account_payment_term","oacc_account.group_operation_admin_invoice",1,1,1,1 +"access_acc_account_payment_term_line_group_operation_admin_invoice","account_payment_term_line group_operation_admin_invoice","account.model_account_payment_term_line","oacc_account.group_operation_admin_invoice",0,0,1,1 diff --git a/views/account_payment_term_views.xml b/views/account_payment_term_views.xml new file mode 100644 index 0000000000000000000000000000000000000000..2ba4b0e74f9eb00fded4854408f6d60c5cfea497 --- /dev/null +++ b/views/account_payment_term_views.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- + Copyright 2024- Le Filament (https://le-filament.com) + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + --> +<odoo> + <record id="account_payment_term_form_oacc_inherit" model="ir.ui.view"> + <field name="name">account.payment.term.form.oacc</field> + <field name="model">account.payment.term</field> + <field name="inherit_id" ref="account.view_payment_term_form" /> + <field name="priority" eval="101" /> + <field name="arch" type="xml"> + <field name="name" position="after"> + <field name="days_offset" /> + </field> + <xpath expr="//field[@name='company_id']" position="attributes"> + <attribute name="required">1</attribute> + </xpath> + <xpath expr="//label[@for='display_on_invoice']" position="attributes"> + <attribute name="invisible">1</attribute> + </xpath> + <field name="display_on_invoice" position="attributes"> + <attribute name="invisible">1</attribute> + </field> + <xpath expr="//separator" position="attributes"> + <attribute name="invisible">1</attribute> + </xpath> + <xpath expr="//p[hasclass('text-muted')]" position="attributes"> + <attribute name="invisible">1</attribute> + </xpath> + <field name="line_ids" position="attributes"> + <attribute name="invisible">1</attribute> + </field> + <xpath expr="//field[@name='example_invalid']/.." position="attributes"> + <attribute name="invisible">1</attribute> + </xpath> + </field> + </record> + <record id="view_payment_term_tree_oacc_inherit" model="ir.ui.view"> + <field name="name">account.payment.term.tree.oacc</field> + <field name="model">account.payment.term</field> + <field name="inherit_id" ref="account.view_payment_term_tree" /> + <field name="priority" eval="101" /> + <field name="arch" type="xml"> + <field name="name" position="after"> + <field name="days_offset" /> + </field> + </field> + </record> +</odoo> diff --git a/views/menu_views.xml b/views/menu_views.xml index 32454add7f4b0375e8fbb26871cd0fd5e728e6d5..4b3f37c3ca7513e12383fe7015d7ebb524cf9418 100644 --- a/views/menu_views.xml +++ b/views/menu_views.xml @@ -38,6 +38,14 @@ name="Ordres de prélèvement" /> + <!-- Menu Elocoop / Facturation / Conditions de paiement --> + <menuitem + parent="menu_acc_invoice" + id="menu_acc_invoicing_payment_term" + sequence="40" + name="Conditions de paiement" + action="account.action_payment_term_form" + /> <!-- Menu Elocoop / Configuration / Facturation --> <menuitem diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml index 337dce9a7e54b523df020d0efe5f887838442226..6a75e2400467a8e9c61eafe05a493e6bded50ebe 100644 --- a/views/res_partner_views.xml +++ b/views/res_partner_views.xml @@ -194,6 +194,15 @@ name="groups" >account.group_account_invoice,account.group_account_readonly</attribute> </xpath> + <!-- group_operation_admin_invoice autoriser la modification de la condition de paiement --> + <xpath + expr="//page[@name='sales_purchases']//group[@name='sale']//field[@name='property_payment_term_id']" + position="attributes" + > + <attribute + name="groups" + >account.group_account_invoice,account.group_account_readonly,oacc_account.group_operation_admin_invoice</attribute> + </xpath> <xpath expr="//page[@name='accounting']" position="attributes"> <attribute name="groups"