forked from Yaltik/golem
[ADD]GOLEM Member Account : add smart button for payments
Also improve the method for opening invoices and store whole amount paid.
This commit is contained in:
parent
037a69d09e
commit
22df2eea36
@ -19,7 +19,8 @@
|
||||
{
|
||||
'name': 'GOLEM members account',
|
||||
'summary': 'GOLEM non-profit members account',
|
||||
'version': '10.0.1.0.1',
|
||||
'description': 'GOLEM non-profit members account',
|
||||
'version': '10.0.1.1.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois, Michel Dessenne',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-02-12 17:49+0000\n"
|
||||
"PO-Revision-Date: 2018-02-12 17:49+0000\n"
|
||||
"POT-Creation-Date: 2018-08-03 07:43+0000\n"
|
||||
"PO-Revision-Date: 2018-08-03 09:44+0200\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -20,6 +20,11 @@ msgstr ""
|
||||
msgid "<span class=\"o_stat_text\">Invoiced</span>"
|
||||
msgstr "<span class=\"o_stat_text\">Facturé</span>"
|
||||
|
||||
#. module: golem_member_account
|
||||
#: model:ir.ui.view,arch_db:golem_member_account.golem_member_form_inherit_golem_member_account
|
||||
msgid "<span class=\"o_stat_text\">Paid</span>"
|
||||
msgstr "<span class=\"o_stat_text\">Payé</span>"
|
||||
|
||||
#. module: golem_member_account
|
||||
#: selection:golem.member,last_payment_state:0
|
||||
msgid "Checked"
|
||||
@ -49,3 +54,9 @@ msgstr "Comptabilisé"
|
||||
#: selection:golem.member,last_payment_state:0
|
||||
msgid "Reconciled"
|
||||
msgstr "Lettré"
|
||||
|
||||
#. module: golem_member_account
|
||||
#: model:ir.model.fields,field_description:golem_member_account.field_golem_member_total_paid
|
||||
msgid "Total paid"
|
||||
msgstr "Total payé"
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-02-12 17:50+0000\n"
|
||||
"PO-Revision-Date: 2018-02-12 17:50+0000\n"
|
||||
"POT-Creation-Date: 2018-08-03 07:43+0000\n"
|
||||
"PO-Revision-Date: 2018-08-03 07:43+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -20,6 +20,11 @@ msgstr ""
|
||||
msgid "<span class=\"o_stat_text\">Invoiced</span>"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_account
|
||||
#: model:ir.ui.view,arch_db:golem_member_account.golem_member_form_inherit_golem_member_account
|
||||
msgid "<span class=\"o_stat_text\">Paid</span>"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_account
|
||||
#: selection:golem.member,last_payment_state:0
|
||||
msgid "Checked"
|
||||
@ -50,3 +55,8 @@ msgstr ""
|
||||
msgid "Reconciled"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_account
|
||||
#: model:ir.model.fields,field_description:golem_member_account.field_golem_member_total_paid
|
||||
msgid "Total paid"
|
||||
msgstr ""
|
||||
|
||||
|
@ -25,22 +25,56 @@ class GolemMember(models.Model):
|
||||
""" GOLEM Member adaptations """
|
||||
_inherit = 'golem.member'
|
||||
|
||||
total_paid = fields.Monetary(compute='_compute_total_paid', store=True,
|
||||
groups='account.group_account_invoice')
|
||||
last_payment_state = fields.Selection([('draft', 'Draft'),
|
||||
('posted', 'Posted'),
|
||||
('checked', 'Checked'),
|
||||
('reconciled', 'Reconciled')],
|
||||
compute='_compute_last_payment_state')
|
||||
|
||||
@api.depends('invoice_ids.payment_ids', 'invoice_ids.payment_ids.state',
|
||||
'invoice_ids.payment_ids.amount')
|
||||
def _compute_total_paid(self):
|
||||
""" Computes total paid """
|
||||
for member in self:
|
||||
payments = member.invoice_ids.mapped('payment_ids')
|
||||
member.total_paid = sum(
|
||||
payments.filtered(lambda p: p.state != 'draft').mapped('amount')
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def open_partner_invoices(self):
|
||||
""" Open member invoices """
|
||||
self.ensure_one()
|
||||
action = self.env.ref('account.action_invoice_tree1')
|
||||
context = {'type':'out_invoice', 'journal_type': 'sale',
|
||||
'search_default_partner_id': self[0].partner_id.id,
|
||||
'default_partner_id': self[0].partner_id.id}
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': 'Invoices',
|
||||
'name': action.name,
|
||||
'res_model': 'account.invoice',
|
||||
'view_mode': 'tree,form',
|
||||
'context': {'search_default_partner_id': self[0].partner_id.id,
|
||||
'default_partner_id': self[0].partner_id.id}}
|
||||
'view_type': action.view_type,
|
||||
'view_mode': action.view_mode,
|
||||
'domain': action.domain,
|
||||
'context': context}
|
||||
|
||||
@api.multi
|
||||
def open_partner_payments(self):
|
||||
""" Open member payments """
|
||||
self.ensure_one()
|
||||
action = self.env.ref('account.action_account_payments')
|
||||
context = {'default_payment_type': 'inbound',
|
||||
'default_partner_type': 'customer',
|
||||
'search_default_partner_id': self[0].partner_id.id,
|
||||
'default_partner_id': self[0].partner_id.id}
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'name': action.name,
|
||||
'res_model': 'account.payment',
|
||||
'view_type': action.view_type,
|
||||
'view_mode': action.view_mode,
|
||||
'domain': action.domain,
|
||||
'context': context}
|
||||
|
||||
@api.depends('invoice_ids')
|
||||
def _compute_last_payment_state(self):
|
||||
|
@ -27,6 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="model">golem.member</field>
|
||||
<field name="inherit_id" ref="golem_member.golem_member_form" />
|
||||
<field name="arch" type="xml">
|
||||
<form position="inside">
|
||||
<field name="currency_id" invisible="1" />
|
||||
</form>
|
||||
<div name="buttons" position="inside">
|
||||
<button type="object" class="oe_stat_button" id="invoice_button"
|
||||
icon="fa-pencil-square-o" name="open_partner_invoices"
|
||||
@ -39,11 +42,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<span class="o_stat_text">Invoiced</span>
|
||||
</div>
|
||||
</button>
|
||||
<button type="object" class="oe_stat_button" id="payment_button"
|
||||
icon="fa-money" name="open_partner_payments"
|
||||
context="{'default_partner_id': active_id}">
|
||||
<div class="o_form_field o_stat_info">
|
||||
<span class="o_stat_value">
|
||||
<field name="total_paid" widget='monetary'
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</span>
|
||||
<span class="o_stat_text">Paid</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<field name="comment" position="before">
|
||||
<field name="last_payment_state" />
|
||||
<field name="currency_id" invisible="1" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user