diff --git a/__manifest__.py b/__manifest__.py index c917ebb6d27e42763c6442a6423734e126f0af70..e1b81f1d5b153b64b1c73a562440ab134da5f150 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -15,5 +15,6 @@ "report/account_invoice_employee_report.xml", # views "views/account_invoice_views.xml", + "views/res_partner_views.xml", ], } diff --git a/models/account_invoice_employee_assign.py b/models/account_invoice_employee_assign.py index a1cb877bf33a33e9802a15f6be30913d1ec9fb58..96ccb24e55f2ade91cc83cf603aa8494210b8164 100644 --- a/models/account_invoice_employee_assign.py +++ b/models/account_invoice_employee_assign.py @@ -12,20 +12,19 @@ class AccountInvoiceEmployeeAssign(models.Model): @api.model def _get_partner_domain(self): partner_ids = self.env.ref("base.main_partner") - partner_ids += self.env["hr.employee"].search( - []).mapped("user_id").mapped("partner_id") + partner_ids += ( + self.env["hr.employee"].search([]).mapped("user_id").mapped("partner_id") + ) return [("id", "in", partner_ids.ids)] invoice_id = fields.Many2one( - comodel_name="account.invoice", - string="Facture", - required=True + comodel_name="account.invoice", string="Facture", required=True ) partner_id = fields.Many2one( comodel_name="res.partner", string="Employé", domain=_get_partner_domain, - required=True + required=True, ) percentage = fields.Float("Pourcentage", default=0.0, required=True) @@ -36,6 +35,4 @@ class AccountInvoiceEmployeeAssign(models.Model): def _check_percentage(self): for record in self: if record.percentage < 0 or record.percentage > 100: - raise UserError(_( - "Le pourcentage doit être entre 0 et 100" - )) + raise UserError(_("Le pourcentage doit être entre 0 et 100")) diff --git a/report/__init__.py b/report/__init__.py old mode 100755 new mode 100644 diff --git a/report/account_invoice_employee_report.py b/report/account_invoice_employee_report.py index 481137a26c5ceacdd0aa9fe2d7130f09e2b84b34..29159f5313873d4162f58f3c6a3d1ff1e900183d 100644 --- a/report/account_invoice_employee_report.py +++ b/report/account_invoice_employee_report.py @@ -1,8 +1,7 @@ # © 2022 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import tools -from odoo import models, fields, api +from odoo import api, fields, models, tools class AccountInvoiceEmployeeReport(models.Model): @@ -32,7 +31,7 @@ class AccountInvoiceEmployeeReport(models.Model): string="Vendeur", readonly=True, ) - currency_id = fields.Many2one("res.currency", string='Currency', readonly=True) + currency_id = fields.Many2one("res.currency", string="Currency", readonly=True) # employee fields partner_id = fields.Many2one( comodel_name="res.partner", @@ -44,10 +43,14 @@ class AccountInvoiceEmployeeReport(models.Model): _depends = { "account.invoice": [ - "state", "user_id", "amount_untaxed_signed", "date_invoice", + "state", + "user_id", + "amount_untaxed_signed", + "date_invoice", ], "account.invoice.employee.assign": [ - "partner_id", "percentage", + "partner_id", + "percentage", ], } @@ -81,10 +84,12 @@ class AccountInvoiceEmployeeReport(models.Model): @api.model_cr def init(self): tools.drop_view_if_exists(self.env.cr, self._table) - self.env.cr.execute("""CREATE or REPLACE VIEW %s as ( + self.env.cr.execute( + """CREATE or REPLACE VIEW %s as ( %s - )""" % ( - self._table, self._query())) + )""" + % (self._table, self._query()) + ) # ------------------------------------------------------ # Computed fields diff --git a/report/account_invoice_employee_report.xml b/report/account_invoice_employee_report.xml index d8599ea7e5c75216a8b8d40e2e0222e712145c0d..493a282e000d2e064f08912bff773a32c0c16c94 100644 --- a/report/account_invoice_employee_report.xml +++ b/report/account_invoice_employee_report.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <!-- SEARCH VIEW --> @@ -7,13 +7,25 @@ <field name="model">account.invoice.employee.report</field> <field name="arch" type="xml"> <search string="Facturation par employé"> - <field name="partner_id"/> - <field name="invoice_id"/> - <field name="user_id"/> + <field name="partner_id" /> + <field name="invoice_id" /> + <field name="user_id" /> <group expand="0" string="Group By"> - <filter name="group_by_date" string="Date de facturation" context="{'group_by':'date_invoice'}"/> - <filter name="group_by_employee" string="Employé" context="{'group_by':'partner_id'}"/> - <filter name="group_by_state" string="Statut" context="{'group_by':'state'}"/> + <filter + name="group_by_date" + string="Date de facturation" + context="{'group_by':'date_invoice'}" + /> + <filter + name="group_by_employee" + string="Employé" + context="{'group_by':'partner_id'}" + /> + <filter + name="group_by_state" + string="Statut" + context="{'group_by':'state'}" + /> </group> </search> </field> @@ -26,14 +38,14 @@ <field name="arch" type="xml"> <tree string="Facturation par employé"> <field name="currency_id" invisible="1" /> - <field name="date_invoice"/> - <field name="partner_id"/> - <field name="percentage"/> + <field name="date_invoice" /> + <field name="partner_id" /> + <field name="percentage" /> <field name="revenue" widget="monetary" /> - <field name="user_id"/> - <field name="invoice_id"/> - <field name="amount_untaxed_signed"/> - <field name="state"/> + <field name="user_id" /> + <field name="invoice_id" /> + <field name="amount_untaxed_signed" /> + <field name="state" /> </tree> </field> </record> @@ -45,9 +57,9 @@ <field name="arch" type="xml"> <pivot string="Facturation par employé"> <field name="currency_id" invisible="1" /> - <field name="partner_id" type="row"/> - <field name="date_invoice" type="col"/> - <field name="revenue" type="measure"/> + <field name="partner_id" type="row" /> + <field name="date_invoice" type="col" /> + <field name="revenue" type="measure" /> </pivot> </field> </record> @@ -59,13 +71,16 @@ <field name="arch" type="xml"> <graph string="Facturation par employé"> <field name="partner_id" /> - <field name="revenue" type="measure"/> + <field name="revenue" type="measure" /> </graph> </field> </record> <!-- ACTION --> - <record id="account_invoice_employee_report_action" model="ir.actions.act_window"> + <record + id="account_invoice_employee_report_action" + model="ir.actions.act_window" + > <field name="name">Rapports Legicoop</field> <field name="type">ir.actions.act_window</field> <field name="res_model">account.invoice.employee.report</field> diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv index 62f4e98040551fa163bbc84fed97f96a8d73363f..5abf4840193b6124fd8038d5b3b4cc5824184518 100644 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_account_invoice_employee_assign,access_account_invoice_employee_assign,model_account_invoice_employee_assign,account.group_account_invoice,1,1,1,1 -access_account_invoice_employee_report,access_account_invoice_employee_report,model_account_invoice_employee_report,account.group_account_invoice,1,1,1,1 \ No newline at end of file +access_account_invoice_employee_report,access_account_invoice_employee_report,model_account_invoice_employee_report,account.group_account_invoice,1,1,1,1 diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml new file mode 100644 index 0000000000000000000000000000000000000000..ba54a631ec82b63eab0dd9d43ccb4bb61cffe698 --- /dev/null +++ b/views/res_partner_views.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" ?> +<!-- Copyright 2020 Le Filament + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> +<odoo> + <data> + <record id="legicoop_account_view_partner_form" model="ir.ui.view"> + <field name="name">legicoop.account.view.partner.form</field> + <field name="model">res.partner</field> + <field name="inherit_id" ref="base.view_partner_form" /> + <field name="priority" eval="110" /> + <field name="arch" type="xml"> + <!-- no_edit sur les champs des comptes comptables --> + <xpath + expr="//field[@name='property_account_receivable_id']" + position="attributes" + > + <attribute name="options">{'no_open': 1}</attribute> + </xpath> + <xpath + expr="//field[@name='property_account_payable_id']" + position="attributes" + > + <attribute name="options">{'no_open': 1}</attribute> +- </xpath> + </field> + </record> + </data> +</odoo>