diff --git a/__init__.py b/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0650744f6bc69b9f0b865e8c7174c813a5f5995e 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..cba8f31e330972145d7414de228b595ff7863655 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,3 @@ +from . import account +from . import res_users +from . import sale diff --git a/models/account.py b/models/account.py new file mode 100644 index 0000000000000000000000000000000000000000..9cb8e11f1fdedd39f0b6effed0bf822acb0bc21c --- /dev/null +++ b/models/account.py @@ -0,0 +1,51 @@ +# Copyright 2021- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class AccountInvoice(models.Model): + _inherit = "account.move" + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + user_second_ids = fields.Many2many( + comodel_name="res.users", + column1="invoice_id", + column2="user_id", + string="Spécialistes", + track_visibility="onchange", + copy=False, + ) + user_provider_id = fields.Many2one( + "res.partner", string="Apporteur", track_visibility="onchange", copy=False + ) + + # ------------------------------------------------------ + # SQL Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Default methods + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD methods (ORM overrides) + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Business methods + # ------------------------------------------------------ diff --git a/models/res_users.py b/models/res_users.py new file mode 100644 index 0000000000000000000000000000000000000000..e4e9a9e4f6bf8b03bf51c1ee4e511538a2b1d1cd --- /dev/null +++ b/models/res_users.py @@ -0,0 +1,26 @@ +# Copyright 2021- Le Filament (https://le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + order_second_ids = fields.Many2many( + comodel_name="sale.order", + column1="user_id", + column2="order_id", + string="Commandes", + copy=False, + ) + invoice_second_ids = fields.Many2many( + comodel_name="account.move", + column1="user_id", + column2="invoice_id", + string="Factures", + copy=False, + ) diff --git a/models/sale.py b/models/sale.py new file mode 100644 index 0000000000000000000000000000000000000000..d098e488e821b11e41fe4be976a3cd06b1e9379d --- /dev/null +++ b/models/sale.py @@ -0,0 +1,60 @@ +# Copyright 2021- Le Filament (https://le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + # ------------------------------------------------------ + # Fields declaration + # ------------------------------------------------------ + user_second_ids = fields.Many2many( + comodel_name="res.users", + column1="order_id", + column2="user_id", + string="Spécialistes", + track_visibility="onchange", + copy=False, + ) + user_provider_id = fields.Many2one( + "res.partner", string="Apporteur", track_visibility="onchange", copy=False + ) + + # ------------------------------------------------------ + # SQL Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Default methods + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Onchange / Constraints + # ------------------------------------------------------ + + # ------------------------------------------------------ + # CRUD methods (ORM overrides) + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Actions + # ------------------------------------------------------ + + # ------------------------------------------------------ + # Business methods + # ------------------------------------------------------ + def _prepare_invoice(self): + values = super()._prepare_invoice() + values.update( + { + "user_second_ids": fields.Command.create(self.user_second_ids.ids), + "user_provider_id": self.user_provider_id.id or False, + } + ) + return values diff --git a/views/account_views.xml b/views/account_views.xml new file mode 100644 index 0000000000000000000000000000000000000000..d8d679c2edc51868cb84fa7c31ef2c32fb0b21e9 --- /dev/null +++ b/views/account_views.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2019- Le Filament (https://le-filament.com) + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> +<odoo> + <record id="account_move_3ad_form" model="ir.ui.view"> + <field name="name">account.3a.move.form</field> + <field name="model">account.move</field> + <field name="inherit_id" ref="account.view_move_form" /> + <field name="arch" type="xml"> + <field name="invoice_user_id" position="after"> + <field + name="user_second_ids" + options="{'no_create_edit': 1}" + widget="many2many_tags" + /> + <field name="user_provider_id" options="{'no_create_edit': 1}" /> + </field> + </field> + </record> +</odoo> diff --git a/views/sale_views.xml b/views/sale_views.xml new file mode 100644 index 0000000000000000000000000000000000000000..b4ba2044d6faeaae0ba10700326e2bc85f1a3d7f --- /dev/null +++ b/views/sale_views.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2019- Le Filament (https://le-filament.com) + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> +<odoo> + <record id="view_order_form" model="ir.ui.view"> + <field name="name">sale.3a.order.form</field> + <field name="model">sale.order</field> + <field name="inherit_id" ref="sale.view_order_form" /> + <field name="arch" type="xml"> + <xpath + expr="//notebook//page[@name='other_information']//group//group//field[@name='user_id']" + position="after" + > + <field + name="user_second_ids" + options="{'no_create_edit': 1}" + widget="many2many_tags" + /> + <field + name="user_provider_id" + options="{'no_create_edit': 1}" + /> + </xpath> + </field> + </record> +</odoo>