Skip to content
Snippets Groups Projects
Commit 439cb750 authored by Benjamin - Le Filament's avatar Benjamin - Le Filament
Browse files

[update] number sequence attribution & invoice template (with tva on company)

parent 76513813
Branches
No related tags found
No related merge requests found
......@@ -16,6 +16,8 @@
# views
'views/membership_membership_line.xml',
'views/res_partner.xml',
# templates
'templates/report_invoice_document.xml',
# wizard
'wizard/membership_import.xml',
],
......
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_move
from . import res_partner
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
class AccountMove(models.Model):
_inherit = 'account.move'
def action_post(self):
"""
Surcharge la fonciton parente pour attribuer automatiquement
un numéro d'adhérent
"""
if self.partner_id.membership_number == 0:
membership_lines = self.line_ids.filtered(
lambda line: line.move_id.move_type == 'out_invoice' and line.product_id.membership)
if membership_lines:
self.partner_id.write({
'membership_number': self.env['ir.sequence'].sudo().next_by_code('afac.membership.number')
})
res = super(AccountMove, self).action_post()
return res
......@@ -10,8 +10,6 @@ class ResPartner(models.Model):
# Company Fields
membership_number = fields.Integer(
string='N° Adhérent',
compute='_compute_membership_number',
store=True
)
membership_contact_id = fields.Many2one(
comodel_name='res.partner',
......@@ -40,11 +38,6 @@ class ResPartner(models.Model):
# ------------------------------------------------------
# Computed fields / Search Fields
# ------------------------------------------------------
@api.depends('membership_state')
def _compute_membership_number(self):
for partner in self:
if partner.membership_number == 0 and partner.membership_state != 'none':
self.membership_number = self.env['ir.sequence'].next_by_code('afac.membership.number')
# ------------------------------------------------------
# Onchange / Constraints
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 Le Filament
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data>
<template id="afac_report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//div[@name='invoice_date']" position="after">
<div class="col-auto col-3 mw-100 mb-2" t-if="o.partner_id.membership_number > 0 and o.move_type == 'out_invoice' and o.state == 'posted'" name="membership_number">
<strong>N° Adhérent :</strong>
<p class="m-0" t-field="o.partner_id.membership_number"/>
</div>
</xpath>
</template>
</data>
</odoo>
\ No newline at end of file
......@@ -119,6 +119,14 @@
groups="base.group_erp_manager"
/>
<!-- Articles -->
<menuitem name="Articles d'adhésion"
id="menu_membership_products"
sequence="102"
parent="account.menu_finance_receivables"
action="membership.action_membership_products"
/>
</data>
</odoo>
......@@ -56,43 +56,7 @@
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='free_member']" position="before">
<field name="membership_number"/>
</xpath>
<xpath expr="//button[@name='%(membership.action_membership_invoice_view)d']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='associate_member']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='member_lines']" position="before">
<separator></separator>
<group>
<group>
<field name="membership_mandate_id" options="{'no_create': True}"/>
<field name="membership_delegate_id" options="{'no_create': True}"/>
</group>
<group>
<field name="membership_contact_id" options="{'no_create': True}"/>
</group>
</group>
</xpath>
</field>
</record>
<!-- Form view -->
<record model="ir.ui.view" id="res_partner_membership_form">
<field name="name">res.partner.membership.form.inherit</field>
<field name="inherit_id" ref="membership.view_partner_form"/>
<field name="model">res.partner</field>
<field name="arch" type="xml">
<xpath expr="//page[@name='membership']" position="attributes">
<attribute name="attrs">{'invisible': [('is_company', '!=', True)]}</attribute>
</xpath>
<xpath expr="//field[@name='free_member']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='free_member']" position="before">
<field name="membership_number"/>
<field name="membership_number" readonly="1"/>
</xpath>
<xpath expr="//button[@name='%(membership.action_membership_invoice_view)d']" position="attributes">
<attribute name="invisible">1</attribute>
......@@ -101,7 +65,7 @@
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='member_lines']" position="before">
<separator></separator>
<hr/>
<group>
<group>
<field name="membership_mandate_id" options="{'no_create': True}"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment