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
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,5 +15,6 @@
"report/account_invoice_employee_report.xml",
# views
"views/account_invoice_views.xml",
"views/res_partner_views.xml",
],
}
......@@ -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"))
Le mode du fichier est passé de 100755 à 100644
# © 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
......
......@@ -11,9 +11,21 @@
<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>
......@@ -65,7 +77,10 @@
</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>
......
<?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