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

[update] partner view + pre-commit clean

parent d25ce504
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -15,5 +15,6 @@ ...@@ -15,5 +15,6 @@
"report/account_invoice_employee_report.xml", "report/account_invoice_employee_report.xml",
# views # views
"views/account_invoice_views.xml", "views/account_invoice_views.xml",
"views/res_partner_views.xml",
], ],
} }
...@@ -12,20 +12,19 @@ class AccountInvoiceEmployeeAssign(models.Model): ...@@ -12,20 +12,19 @@ class AccountInvoiceEmployeeAssign(models.Model):
@api.model @api.model
def _get_partner_domain(self): def _get_partner_domain(self):
partner_ids = self.env.ref("base.main_partner") partner_ids = self.env.ref("base.main_partner")
partner_ids += self.env["hr.employee"].search( partner_ids += (
[]).mapped("user_id").mapped("partner_id") self.env["hr.employee"].search([]).mapped("user_id").mapped("partner_id")
)
return [("id", "in", partner_ids.ids)] return [("id", "in", partner_ids.ids)]
invoice_id = fields.Many2one( invoice_id = fields.Many2one(
comodel_name="account.invoice", comodel_name="account.invoice", string="Facture", required=True
string="Facture",
required=True
) )
partner_id = fields.Many2one( partner_id = fields.Many2one(
comodel_name="res.partner", comodel_name="res.partner",
string="Employé", string="Employé",
domain=_get_partner_domain, domain=_get_partner_domain,
required=True required=True,
) )
percentage = fields.Float("Pourcentage", default=0.0, required=True) percentage = fields.Float("Pourcentage", default=0.0, required=True)
...@@ -36,6 +35,4 @@ class AccountInvoiceEmployeeAssign(models.Model): ...@@ -36,6 +35,4 @@ class AccountInvoiceEmployeeAssign(models.Model):
def _check_percentage(self): def _check_percentage(self):
for record in self: for record in self:
if record.percentage < 0 or record.percentage > 100: if record.percentage < 0 or record.percentage > 100:
raise UserError(_( raise UserError(_("Le pourcentage doit être entre 0 et 100"))
"Le pourcentage doit être entre 0 et 100"
))
Le mode du fichier est passé de 100755 à 100644
# © 2022 Le Filament (<http://www.le-filament.com>) # © 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import tools from odoo import api, fields, models, tools
from odoo import models, fields, api
class AccountInvoiceEmployeeReport(models.Model): class AccountInvoiceEmployeeReport(models.Model):
...@@ -32,7 +31,7 @@ class AccountInvoiceEmployeeReport(models.Model): ...@@ -32,7 +31,7 @@ class AccountInvoiceEmployeeReport(models.Model):
string="Vendeur", string="Vendeur",
readonly=True, readonly=True,
) )
currency_id = fields.Many2one("res.currency", string='Currency', readonly=True) currency_id = fields.Many2one("res.currency", string="Currency", readonly=True)
# employee fields # employee fields
partner_id = fields.Many2one( partner_id = fields.Many2one(
comodel_name="res.partner", comodel_name="res.partner",
...@@ -44,10 +43,14 @@ class AccountInvoiceEmployeeReport(models.Model): ...@@ -44,10 +43,14 @@ class AccountInvoiceEmployeeReport(models.Model):
_depends = { _depends = {
"account.invoice": [ "account.invoice": [
"state", "user_id", "amount_untaxed_signed", "date_invoice", "state",
"user_id",
"amount_untaxed_signed",
"date_invoice",
], ],
"account.invoice.employee.assign": [ "account.invoice.employee.assign": [
"partner_id", "percentage", "partner_id",
"percentage",
], ],
} }
...@@ -81,10 +84,12 @@ class AccountInvoiceEmployeeReport(models.Model): ...@@ -81,10 +84,12 @@ class AccountInvoiceEmployeeReport(models.Model):
@api.model_cr @api.model_cr
def init(self): def init(self):
tools.drop_view_if_exists(self.env.cr, self._table) 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 %s
)""" % ( )"""
self._table, self._query())) % (self._table, self._query())
)
# ------------------------------------------------------ # ------------------------------------------------------
# Computed fields # Computed fields
......
...@@ -11,9 +11,21 @@ ...@@ -11,9 +11,21 @@
<field name="invoice_id" /> <field name="invoice_id" />
<field name="user_id" /> <field name="user_id" />
<group expand="0" string="Group By"> <group expand="0" string="Group By">
<filter name="group_by_date" string="Date de facturation" context="{'group_by':'date_invoice'}"/> <filter
<filter name="group_by_employee" string="Employé" context="{'group_by':'partner_id'}"/> name="group_by_date"
<filter name="group_by_state" string="Statut" context="{'group_by':'state'}"/> 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> </group>
</search> </search>
</field> </field>
...@@ -65,7 +77,10 @@ ...@@ -65,7 +77,10 @@
</record> </record>
<!-- ACTION --> <!-- 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="name">Rapports Legicoop</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">account.invoice.employee.report</field> <field name="res_model">account.invoice.employee.report</field>
......
<?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>
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