From 9005ffb060ee2621b5d736f957a410fbd1647d95 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 4 Apr 2014 10:47:18 +0200 Subject: [PATCH 001/172] Initial check-in with several modules. --- donation/__init__.py | 25 ++ donation/__openerp__.py | 54 ++++ donation/campaign_user_view.xml | 29 ++ donation/donation.py | 372 ++++++++++++++++++++++++ donation/donation_campaign.py | 40 +++ donation/donation_campaign_view.xml | 51 ++++ donation/donation_data.xml | 26 ++ donation/donation_demo.xml | 17 ++ donation/donation_view.xml | 149 ++++++++++ donation/i18n/donation.pot | 211 ++++++++++++++ donation/i18n/fr.po | 211 ++++++++++++++ donation/product.py | 43 +++ donation/product_demo.xml | 23 ++ donation/product_view.xml | 30 ++ donation/security/._ir.model.access.csv | Bin 0 -> 4096 bytes donation/security/donation_security.xml | 25 ++ donation/security/ir.model.access.csv | 12 + 17 files changed, 1318 insertions(+) create mode 100644 donation/__init__.py create mode 100644 donation/__openerp__.py create mode 100644 donation/campaign_user_view.xml create mode 100644 donation/donation.py create mode 100644 donation/donation_campaign.py create mode 100644 donation/donation_campaign_view.xml create mode 100644 donation/donation_data.xml create mode 100644 donation/donation_demo.xml create mode 100644 donation/donation_view.xml create mode 100644 donation/i18n/donation.pot create mode 100644 donation/i18n/fr.po create mode 100644 donation/product.py create mode 100644 donation/product_demo.xml create mode 100644 donation/product_view.xml create mode 100644 donation/security/._ir.model.access.csv create mode 100644 donation/security/donation_security.xml create mode 100644 donation/security/ir.model.access.csv diff --git a/donation/__init__.py b/donation/__init__.py new file mode 100644 index 000000000..20ca7d841 --- /dev/null +++ b/donation/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Barroux Abbey +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import donation_campaign +from . import donation +from . import product + diff --git a/donation/__openerp__.py b/donation/__openerp__.py new file mode 100644 index 000000000..3c07c25cc --- /dev/null +++ b/donation/__openerp__.py @@ -0,0 +1,54 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Abbaye du Barroux +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Donation', + 'version': '0.1', + 'category': 'Accounting & Finance', + 'license': 'AGPL-3', + 'summary': 'Manage donations', + 'description': """ +Donation +======== + +This module handles donations. + +It has been developped by brother Bernard and brother Irenee from Barroux Abbey and by Alexis de Lattre from Akretion. + """, + 'author': 'Barroux, Akretion', + 'website': 'http://www.barroux.org', + 'depends': ['account_accountant'], + 'data': [ + 'security/donation_security.xml', + 'donation_view.xml', + 'donation_data.xml', + 'product_view.xml', + 'donation_campaign_view.xml', + 'campaign_user_view.xml', + 'security/ir.model.access.csv', + ], + 'demo': [ + 'product_demo.xml', + 'donation_demo.xml', + ], + 'active': False, +} diff --git a/donation/campaign_user_view.xml b/donation/campaign_user_view.xml new file mode 100644 index 000000000..aee63d3fb --- /dev/null +++ b/donation/campaign_user_view.xml @@ -0,0 +1,29 @@ + + + + + + + donation.res.users.form + res.users + + + + + + + + + + donation.preferences.res.users.form + res.users + + + + + + + + + + diff --git a/donation/donation.py b/donation/donation.py new file mode 100644 index 000000000..074d32f8f --- /dev/null +++ b/donation/donation.py @@ -0,0 +1,372 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Barroux Abbey +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields +import openerp.addons.decimal_precision as dp +from openerp.tools.translate import _ +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT +from datetime import datetime + + +class res_users(orm.Model): + _inherit = 'res.users' + + _columns = { + 'context_donation_campaign_id': fields.many2one('donation.campaign', 'Donation Campaign User'), # begin with context_... + } + + +class donation_donation(orm.Model): + _name = 'donation.donation' + _description = 'Donations' + _order = 'id desc' + _rec_name = 'number' + + def _compute_total(self, cr, uid, ids, name, arg, context=None): + print "_compute_total ids=", ids + res = {} # key = ID, value : amount_total + for donation in self.browse(cr, uid, ids, context=context): + total = 0.0 + for line in donation.line_ids: + total += line.quantity * line.unit_price + res[donation.id] = total + print "_compute_total res=", total + return res + + def _get_donation_from_lines(self, cr, uid, ids, context=None): + res = self.pool['donation.donation'].search( + cr, uid, [('line_ids', 'in', ids)], context=context) + return res + + def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): + res = {} + for donation in self.browse(cr, uid, ids, context=context): + if donation.journal_id.currency: + res[donation.id] = donation.journal_id.currency.id + else: + res[donation.id] = donation.company_id.currency_id.id + return res + + _columns = { + 'number': fields.char( + 'Donation Number', size=32, readonly=True), + 'currency_id': fields.function( + _get_donation_currency, type='many2one', relation='res.currency', + string='Currency'), + 'partner_id': fields.many2one( + 'res.partner', 'Donator', required=True, + states={'done': [('readonly', True)]}), + 'check_total': fields.float( + 'Check Amount', digits_compute=dp.get_precision('Account'), + states={'done': [('readonly', True)]}), + 'amount_total': fields.function( + _compute_total, type='float', string='Amount Total', store={ + 'donation.line': (_get_donation_from_lines, ['unit_price', 'quantity', 'donation_id'], 10), + }), + 'donation_date': fields.date( + 'Donation Date', required=True, + states={'done': [('readonly', True)]}), + 'company_id': fields.many2one( + 'res.company', 'Company', required=True, + states={'done': [('readonly', True)]}), + 'line_ids': fields.one2many( + 'donation.line', 'donation_id', 'Donation Lines', + states={'done': [('readonly', True)]}), + 'move_id': fields.many2one( + 'account.move', 'Account Move', readonly=True), + 'journal_id': fields.many2one( + 'account.journal', 'Payment Method', required=True, + domain=[('type', '=', 'donation')], + states={'done': [('readonly', True)]}), + 'state': fields.selection([ + ('draft', 'Draft'), + ('done', 'Done'), + ], 'State', readonly=True), + 'company_currency_id': fields.related( + 'company_id', 'currency_id', type='many2one', + relation="res.currency", string="Company Currency"), + #'origin_id': fields.many2one('donation.origin', 'Origin of Donation'), + 'donation_campaign_id': fields.many2one( + 'donation.campaign', 'Donation Campaign'), + 'create_uid': fields.many2one('res.users', 'Created by'), + } + + def _get_default_currency(self, cr, uid, context=None): + company_id = self.pool['res.company']._company_default_get( + cr, uid, 'donation.donation', context=context) + company = self.pool['res.company'].browse( + cr, uid, company_id, context=context) + return company.currency_id.id + + def _get_default_journal(self, cr, uid, context=None): + (model, res_id) = self.pool['ir.model.data'].get_object_reference(cr, uid, 'donation', 'donation_journal') + assert model == 'account.journal', 'Wrong model' + return res_id + + def get_default_campaign(self, cr, uid, context=None): + user = self.pool['res.users'].browse(cr, uid, uid, context=context) # here "ids" = uid where uid contains user access rules + return user.context_donation_campaign_id.id + + + + _defaults = { + 'state': 'draft', + 'company_id': lambda self, cr, uid, context: \ + self.pool['res.company']._company_default_get( + cr, uid, 'donation.donation', context=context), + 'currency_id': _get_default_currency, + 'journal_id': _get_default_journal, + 'donation_campaign_id': get_default_campaign, + } + + def _check_donation_date(self, cr, uid, ids): + today_dt = datetime.today() + today_str = today_dt.strftime(DEFAULT_SERVER_DATE_FORMAT) + for donation in self.browse(cr, uid, ids): + if donation.donation_date > today_str: + return False + return True + + _constraints = [( + _check_donation_date, + "Date must be today or in the past", + ['donation_date'] + )] + + _sql_constraints = [( + 'number_company_unique', + 'unique(company_id, number)', + 'A donation with this number already exists for this company' + )] + + def _prepare_donation_move(self, cr, uid, donation, context=None): + if context is None: + context = {} + + if not donation.journal_id.default_debit_account_id: + raise orm.except_orm( + _('Error:'), + _("Missing Default Debit Account on journal '%s'.") + % donation.journal_id.name) + + context['account_period_prefer_normal'] = True + period_search = self.pool['account.period'].find( + cr, uid, donation.donation_date, context=context) + assert len(period_search) == 1, 'We should get one period' + period_id = period_search[0] + + movelines = [] + # Note : we can have negative donations for donators that use direct + # debit when their direct debit rejected by the bank + for donation_line in donation.line_ids: + account_id = donation_line.product_id.property_account_income.id + if not account_id: + account_id = donation_line.product_id.categ_id.property_account_income_categ.id + if not account_id: + raise orm.except_orm( + _('Error:'), + _("Missing income account on product '%s' or on it's related product category") % donation_line.product_id.name) + if donation_line.amount > 0: + credit = donation_line.amount + debit = 0 + else: + debit = donation_line.amount * -1 + credit = 0 + movelines.append((0, 0, { + 'name': donation_line.product_id.name, + 'credit': credit, + 'debit': debit, + 'account_id': account_id, + })) + + # counter-part + if donation.amount_total > 0: + debit = donation.amount_total + credit = 0 + else: + credit = donation.amount_total * -1 + debit = 0 + movelines.append( + (0, 0, { + 'debit': debit, + 'credit': credit, + 'name': _('Don de %s') % donation.partner_id.name, + 'account_id': donation.journal_id.default_debit_account_id.id, + })) + + vals = { + 'journal_id': donation.journal_id.id, + 'date': donation.donation_date, + 'period_id': period_id, + 'ref': _('Don %s de %s') % (donation.number, donation.partner_id.name), + 'line_id': movelines, + } + print "_prepare_donation_move vals=", vals + return vals + + def validate(self, cr, uid, ids, context=None): + assert len(ids) == 1, 'Only one ID accepted' + donation = self.browse(cr, uid, ids[0], context=context) + + if not donation.line_ids: + raise orm.except_orm( + _('Error:'), + _('Cannot validate a donation without lines!')) + + print "donation.check_total=", donation.check_total + print "donation.amount_total=", donation.amount_total + if donation.check_total != donation.amount_total: + raise orm.except_orm( + _('Error:'), + _("The amount of the donation (%s) is different from the sum of the donation lines (%s).") + % (donation.check_total, donation.amount_total)) + + # We only manage donations of the same currency for the moment + if donation.currency_id.id != donation.company_id.currency_id.id: + raise orm.except_orm( + _('Error:'), + _("The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment.") % (donation.currency_id.name, donation.company_id.name, donation.company_id.currency_id.name) + ) + + donation_write_vals = {'state': 'done'} + if donation.amount_total: + move_vals = self._prepare_donation_move( + cr, uid, donation, context=context) + move_id = self.pool['account.move'].create( + cr, uid, move_vals, context=context) + + self.pool['account.move'].post(cr, uid, [move_id], context=context) + donation_write_vals['move_id'] = move_id + + if not donation.number: + donation_write_vals['number'] = self.pool['ir.sequence'].next_by_code( + cr, uid, 'donation.donation', context=context) + + self.write(cr, uid, donation.id, donation_write_vals, context=context) + return + + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} + default['state'] = 'draft' + default['move_id'] = False + default['number'] = False + res = super(donation_donation, self).copy( + cr, uid, id, default=default, context=context) + return res + + def partner_id_change(self, cr, uid, ids, partner_id, context=None): + return {} + + def back_to_draft(self, cr, uid, ids, context=None): + assert len(ids) == 1, 'only one ID for back2draft' + donation = self.browse(cr, uid, ids[0], context=context) + if donation.move_id: + self.pool['account.move'].button_cancel( + cr, uid, [donation.move_id.id], context=context) + self.pool['account.move'].unlink( + cr, uid, donation.move_id.id, context=context) + donation.write({'state': 'draft'}, context=context) + # TODO : does it work if the account.move is reconciled ??? It should not. + return + + +class donation_line(orm.Model): + _name = 'donation.line' + _description = 'Donation Lines' + _rec_name = 'product_id' + + def _compute_amount(self, cr, uid, ids, name, arg, context=None): + res = {} + for line in self.browse(cr, uid, ids, context=context): + res[line.id] = line.quantity * line.unit_price + return res + + _columns = { + 'donation_id': fields.many2one( + 'donation.donation', 'Donation', ondelete='cascade'), + 'product_id': fields.many2one('product.product', 'Product', domain=[('donation_ok', '=', True)]), + 'quantity': fields.integer('Quantity'), + 'unit_price': fields.float( + 'Unit Price', digits_compute=dp.get_precision('Account')), + 'amount': fields.function( + _compute_amount, string='Amount', + digits_compute=dp.get_precision('Account'), store={ + 'donation.line': (lambda self, cr, uid, ids, c={}: ids, ['quantity', 'unit_price'], 10), + }), + 'sequence': fields.integer('Sequence'), + } + + _defaults = { + 'quantity': 1, + } + + def product_id_change(self, cr, uid, ids, product_id, context): + res = {'value': {}} + if product_id: + product = self.pool['product.product'].browse( + cr, uid, product_id, context=context) + res['value']['unit_price'] = product.list_price + return res + + +class res_partner(orm.Model): + _inherit = 'res.partner' + + _columns = { + 'donation_ids': fields.one2many( + 'donation.donation', 'partner_id', 'Donations'), + } + + +class account_journal(orm.Model): + _inherit = 'account.journal' + + _columns = { + 'type': fields.selection([ + ('sale', 'Sale'), + ('sale_refund', 'Sale Refund'), + ('purchase', 'Purchase'), + ('purchase_refund', 'Purchase Refund'), + ('cash', 'Cash'), + ('bank', 'Bank and Checks'), + ('general', 'General'), + ('situation', 'Opening/Closing Situation'), + ('donation', 'Donation'), + ], 'Type', size=32, required=True, + help="Select 'Sale' for customer invoices journals. " + "Select 'Purchase' for supplier invoices journals. " + "Select 'Cash' or 'Bank' for journals that are used in " + "customer or supplier payments. " + "Select 'General' for miscellaneous operations journals. " + "Select 'Opening/Closing Situation' for entries generated for " + " new fiscal years. " + "Select 'Donations' for donation journals." + ), + } + + + + + + + + diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py new file mode 100644 index 000000000..c6c1b3a8a --- /dev/null +++ b/donation/donation_campaign.py @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Barroux Abbey +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields +from openerp.tools import DEFAULT_SERVER_DATE_FORMAT +from datetime import datetime + +class donation_campaign(orm.Model): + _name = 'donation.campaign' + _description = 'Code attributed for a Donation Campaign' + + _columns = { + 'code': fields.char('Code', size=10), + 'name': fields.char('Name', size=64, required=True), + 'campaign_creation_date': fields.date('Campaign Creation Date', readonly=True), + 'nota':fields.text('Notes'), + } + + _defaults = { + 'campaign_creation_date' : fields.date.context_today, + + } diff --git a/donation/donation_campaign_view.xml b/donation/donation_campaign_view.xml new file mode 100644 index 000000000..d2b161666 --- /dev/null +++ b/donation/donation_campaign_view.xml @@ -0,0 +1,51 @@ + + + + + + + + + donation.campaign.form + donation.campaign + +
+ + + + + + + + +
+
+
+ + + donation.campaign.tree + donation.campaign + + + + + + + + + + + Campaign of Donations + donation.campaign + form + tree,form + + + + +
+
diff --git a/donation/donation_data.xml b/donation/donation_data.xml new file mode 100644 index 000000000..6455c2463 --- /dev/null +++ b/donation/donation_data.xml @@ -0,0 +1,26 @@ + + + + + + + Donation Number + donation.donation + + + + Donation + donation.donation + DON-%(year)s- + 4 + + + + + Donation Journal + DON + donation + + + + diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml new file mode 100644 index 000000000..9243161d6 --- /dev/null +++ b/donation/donation_demo.xml @@ -0,0 +1,17 @@ + + + + + + + Quest + + + Prospecting + + + Catalog + + + + diff --git a/donation/donation_view.xml b/donation/donation_view.xml new file mode 100644 index 000000000..29aff6d6c --- /dev/null +++ b/donation/donation_view.xml @@ -0,0 +1,149 @@ + + + + + + + donation.form + donation.donation + +
+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+
+ + + donation.tree + donation.donation + + + + + + + + + + + + + + + + donation.search + donation.donation + + + + + + + + + + + + + + + + donation.line.tree + donation.line + + + + + + + + + + + + + + donation.line.form + donation.line + +
+ + + + + + + + +
+
+
+ + + + Donations + donation.donation + form + tree,form + + + + Donations Lines + donation.line + form + tree,form + + + + + + + + + + + + Donators + res.partner + form + kanban,tree,form + + + + + + Products + product.product + kanban,tree,form + form + {'search_default_filter_to_donation': 1} + + + + +
+
diff --git a/donation/i18n/donation.pot b/donation/i18n/donation.pot new file mode 100644 index 000000000..c5dd2621f --- /dev/null +++ b/donation/i18n/donation.pot @@ -0,0 +1,211 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * donation +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-03-13 08:50+0000\n" +"PO-Revision-Date: 2014-03-13 08:50+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: donation +#: code:addons/donation/donation.py:227 +#, python-format +msgid "Missing price on product" +msgstr "" + +#. module: donation +#: field:donation.donation,state:0 +msgid "State" +msgstr "" + +#. module: donation +#: selection:donation.donation,state:0 +msgid "Draft" +msgstr "" + +#. module: donation +#: view:donation.line:0 +msgid "Donation Line" +msgstr "" + +#. module: donation +#: field:donation.line,product_id:0 +msgid "Product" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:135 +#, python-format +msgid "The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment." +msgstr "" + +#. module: donation +#: field:donation.donation,company_id:0 +msgid "Company" +msgstr "" + +#. module: donation +#: view:donation.donation:0 +#: field:donation.line,donation_id:0 +#: model:res.groups,name:donation.group_donation +msgid "Donation" +msgstr "" + +#. module: donation +#: constraint:donation.donation:0 +msgid "Date must be today or in the past" +msgstr "" + +#. module: donation +#: field:donation.donation,company_currency_id:0 +msgid "Company Currency" +msgstr "" + +#. module: donation +#: field:donation.donation,line_ids:0 +#: model:ir.model,name:donation.model_donation_line +msgid "Donation Lines" +msgstr "" + +#. module: donation +#: field:donation.donation,donation_date:0 +msgid "Donation Date" +msgstr "" + +#. module: donation +#: view:donation.donation:0 +msgid "Validate" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:228 +#, python-format +msgid "The sale price on product '%s' is 0!" +msgstr "" + +#. module: donation +#: field:donation.donation,partner_categ_id:0 +msgid "Categories" +msgstr "" + +#. module: donation +#: sql_constraint:donation.donation:0 +msgid "A donation with this number already exists for this company" +msgstr "" + +#. module: donation +#: field:donation.donation,number:0 +msgid "Donation Number" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:134 +#: code:addons/donation/donation.py:153 +#, python-format +msgid "Error:" +msgstr "" + +#. module: donation +#: model:ir.model,name:donation.model_res_company +msgid "Companies" +msgstr "" + +#. module: donation +#: field:donation.donation,company_email:0 +msgid "Company Email" +msgstr "" + +#. module: donation +#: field:donation.line,amount:0 +msgid "Amount" +msgstr "" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_action +#: model:ir.model,name:donation.model_donation_donation +#: model:ir.ui.menu,name:donation.donation_menu +#: model:ir.ui.menu,name:donation.donation_title_menu +#: view:res.company:0 +msgid "Donations" +msgstr "" + +#. module: donation +#: selection:donation.donation,state:0 +msgid "Waiting Currency Conversion" +msgstr "" + +#. module: donation +#: field:donation.donation,move_id:0 +msgid "Account Move" +msgstr "" + +#. module: donation +#: field:donation.donation,check_total:0 +msgid "Check Amount" +msgstr "" + +#. module: donation +#: field:res.company,donation_bank_account_id:0 +msgid "Bank Account for Donations" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:154 +#, python-format +msgid "Missing income account on product '%s' or on it's related product category" +msgstr "" + +#. module: donation +#: field:donation.line,sequence:0 +msgid "Sequence" +msgstr "" + +#. module: donation +#: sql_constraint:donation.line:0 +msgid "The amount must be positive or 0." +msgstr "" + +#. module: donation +#: field:donation.donation,partner_id:0 +msgid "Donator" +msgstr "" + +#. module: donation +#: field:donation.donation,currency_id:0 +msgid "Currency" +msgstr "" + +#. module: donation +#: selection:donation.donation,state:0 +msgid "Done" +msgstr "" + +#. module: donation +#: model:ir.model,name:donation.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_line_action +#: model:ir.ui.menu,name:donation.donation_line_menu +msgid "Donations Lines" +msgstr "" + +#. module: donation +#: field:donation.donation,journal_id:0 +msgid "Journal" +msgstr "" + +#. module: donation +#: field:donation.donation,amount_total:0 +msgid "Amount Total" +msgstr "" + diff --git a/donation/i18n/fr.po b/donation/i18n/fr.po new file mode 100644 index 000000000..a2e3b5876 --- /dev/null +++ b/donation/i18n/fr.po @@ -0,0 +1,211 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * donation +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-03-13 08:55+0000\n" +"PO-Revision-Date: 2014-03-13 08:55+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: donation +#: code:addons/donation/donation.py:227 +#, python-format +msgid "Missing price on product" +msgstr "Prix manquant sur le produit" + +#. module: donation +#: field:donation.donation,state:0 +msgid "State" +msgstr "État" + +#. module: donation +#: selection:donation.donation,state:0 +msgid "Draft" +msgstr "Brouillon" + +#. module: donation +#: view:donation.line:0 +msgid "Donation Line" +msgstr "Ligne de don" + +#. module: donation +#: field:donation.line,product_id:0 +msgid "Product" +msgstr "Produit" + +#. module: donation +#: code:addons/donation/donation.py:135 +#, python-format +msgid "The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment." +msgstr "The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment." + +#. module: donation +#: field:donation.donation,company_id:0 +msgid "Company" +msgstr "Société" + +#. module: donation +#: view:donation.donation:0 +#: field:donation.line,donation_id:0 +#: model:res.groups,name:donation.group_donation +msgid "Donation" +msgstr "Don" + +#. module: donation +#: constraint:donation.donation:0 +msgid "Date must be today or in the past" +msgstr "Date must be today or in the past" + +#. module: donation +#: field:donation.donation,company_currency_id:0 +msgid "Company Currency" +msgstr "Company Currency" + +#. module: donation +#: field:donation.donation,line_ids:0 +#: model:ir.model,name:donation.model_donation_line +msgid "Donation Lines" +msgstr "Donation Lines" + +#. module: donation +#: field:donation.donation,donation_date:0 +msgid "Donation Date" +msgstr "Date du don" + +#. module: donation +#: view:donation.donation:0 +msgid "Validate" +msgstr "Validate" + +#. module: donation +#: code:addons/donation/donation.py:228 +#, python-format +msgid "The sale price on product '%s' is 0!" +msgstr "The sale price on product '%s' is 0!" + +#. module: donation +#: field:donation.donation,partner_categ_id:0 +msgid "Categories" +msgstr "Categories" + +#. module: donation +#: sql_constraint:donation.donation:0 +msgid "A donation with this number already exists for this company" +msgstr "A donation with this number already exists for this company" + +#. module: donation +#: field:donation.donation,number:0 +msgid "Donation Number" +msgstr "Donation Number" + +#. module: donation +#: code:addons/donation/donation.py:134 +#: code:addons/donation/donation.py:153 +#, python-format +msgid "Error:" +msgstr "Error:" + +#. module: donation +#: model:ir.model,name:donation.model_res_company +msgid "Companies" +msgstr "Sociétés" + +#. module: donation +#: field:donation.donation,company_email:0 +msgid "Company Email" +msgstr "Company Email" + +#. module: donation +#: field:donation.line,amount:0 +msgid "Amount" +msgstr "Amount" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_action +#: model:ir.model,name:donation.model_donation_donation +#: model:ir.ui.menu,name:donation.donation_menu +#: model:ir.ui.menu,name:donation.donation_title_menu +#: view:res.company:0 +msgid "Donations" +msgstr "Donations" + +#. module: donation +#: selection:donation.donation,state:0 +msgid "Waiting Currency Conversion" +msgstr "Waiting Currency Conversion" + +#. module: donation +#: field:donation.donation,move_id:0 +msgid "Account Move" +msgstr "Account Move" + +#. module: donation +#: field:donation.donation,check_total:0 +msgid "Check Amount" +msgstr "Check Amount" + +#. module: donation +#: field:res.company,donation_bank_account_id:0 +msgid "Bank Account for Donations" +msgstr "Bank Account for Donations" + +#. module: donation +#: code:addons/donation/donation.py:154 +#, python-format +msgid "Missing income account on product '%s' or on it's related product category" +msgstr "Missing income account on product '%s' or on it's related product category" + +#. module: donation +#: field:donation.line,sequence:0 +msgid "Sequence" +msgstr "Sequence" + +#. module: donation +#: sql_constraint:donation.line:0 +msgid "The amount must be positive or 0." +msgstr "The amount must be positive or 0." + +#. module: donation +#: field:donation.donation,partner_id:0 +msgid "Donator" +msgstr "Donator" + +#. module: donation +#: field:donation.donation,currency_id:0 +msgid "Currency" +msgstr "Currency" + +#. module: donation +#: selection:donation.donation,state:0 +msgid "Done" +msgstr "Done" + +#. module: donation +#: model:ir.model,name:donation.model_account_invoice +msgid "Invoice" +msgstr "Facture" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_line_action +#: model:ir.ui.menu,name:donation.donation_line_menu +msgid "Donations Lines" +msgstr "Donations Lines" + +#. module: donation +#: field:donation.donation,journal_id:0 +msgid "Journal" +msgstr "Journal" + +#. module: donation +#: field:donation.donation,amount_total:0 +msgid "Amount Total" +msgstr "Amount Total" + diff --git a/donation/product.py b/donation/product.py new file mode 100644 index 000000000..d6505b903 --- /dev/null +++ b/donation/product.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Barroux Abbey +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class product_template(orm.Model): + _inherit = 'product.template' + + _columns = { + 'donation_ok': fields.boolean( + 'Is a Donation', + help="Specify if the product can be selected" + "in a donation line."), + } + + +class product_product(orm.Model): + _inherit = 'product.product' + + def donation_ok_change(self, cr, uid, ids, donation_ok, context=None): + res = {} + if donation_ok: + res['value'] = {'type': 'service', 'sale_ok': False} + return res diff --git a/donation/product_demo.xml b/donation/product_demo.xml new file mode 100644 index 000000000..e8b6695cc --- /dev/null +++ b/donation/product_demo.xml @@ -0,0 +1,23 @@ + + + + + + + Donation + + 0 + 1 + 0 + service + + + This is a donation product. + + + + DON + + + + diff --git a/donation/product_view.xml b/donation/product_view.xml new file mode 100644 index 000000000..2a9f1a982 --- /dev/null +++ b/donation/product_view.xml @@ -0,0 +1,30 @@ + + + + + + + donation.product.product.search + product.product + + + + + + + + + + donation.product.product.form + product.product + + +
+ +
+
+
+ +
+
diff --git a/donation/security/._ir.model.access.csv b/donation/security/._ir.model.access.csv new file mode 100644 index 0000000000000000000000000000000000000000..9793a08533cb9887930a72ee59f899d70cfbe167 GIT binary patch literal 4096 zcmeH~u?oUK42Dxd#13vcNr^8YB5vZ~1Bjp~nS2pVwFq`` z77_@_A1>kYZGrZn11*4+khtFB4r{Aw&?TP&^llVM_wE2eMEMU}#_@)pT;3gUrF_(A z2}sxVzO?x`7t+~WcvXz0aLU6etUe;GE^~tmoXlTZr$&*Q&BJqJAWJ5|1egF5U;<2l z2`~XBzyz286JP?>v03@cqWF*&=u}}#Clw~vWtbYTj8Cl*S|3rX#N%EIlhFlQcl~wv M-v6`85TeK92^+;N8UO$Q literal 0 HcmV?d00001 diff --git a/donation/security/donation_security.xml b/donation/security/donation_security.xml new file mode 100644 index 000000000..364611150 --- /dev/null +++ b/donation/security/donation_security.xml @@ -0,0 +1,25 @@ + + + + + + + Donation + Manage donations + 45 + + + + User + + + + + Manager + + + + + + + diff --git a/donation/security/ir.model.access.csv b/donation/security/ir.model.access.csv new file mode 100644 index 000000000..48adc27de --- /dev/null +++ b/donation/security/ir.model.access.csv @@ -0,0 +1,12 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_donation_donation_user,Full access on donation.donation to Donation User,model_donation_donation,group_donation_user,1,1,1,1 +access_donation_campaign_manager,Full access on donation.campaign to Donation Manager,model_donation_campaign,group_donation_manager,1,1,1,1 +access_donation_campaign_user,Read access on donation.campaign to Donation User,model_donation_campaign,group_donation_user,1,0,0,0 +access_donation_line_user,Full access on donation.line to Donation User,model_donation_line,group_donation_user,1,1,1,1 +access_donation_donation_read,Read access on donation.donation to Employee grp,model_donation_donation,base.group_user,1,0,0,0 +access_donation_line_read,Read access on donation.line to Employee grp,model_donation_line,base.group_user,1,0,0,0 +access_account_period_donation,Read access on account.period,account.model_account_period,group_donation_user,1,0,0,0 +access_account_journal_donation,Read access on account.journal,account.model_account_journal,group_donation_user,1,0,0,0 +access_account_journal_period_donation,Full access on account.journal.period,account.model_account_journal_period,group_donation_user,1,1,1,1 +access_account_move_donation,Full access on account.move,account.model_account_move,group_donation_user,1,1,1,1 +access_account_move_line_donation,Full access on account.move.line,account.model_account_move_line,group_donation_user,1,1,1,1 From 930700a29e28ca9bcaad77ca9006e549fce5f880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A8re=20Bernard?= Date: Fri, 4 Apr 2014 11:18:47 +0200 Subject: [PATCH 002/172] add company_id field on donation request add acl for mass.request.transfer --- donation/security/._ir.model.access.csv | Bin 4096 -> 4096 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/donation/security/._ir.model.access.csv b/donation/security/._ir.model.access.csv index 9793a08533cb9887930a72ee59f899d70cfbe167..1d7850f0b1e4c5b30892789b9980da5e959e7895 100644 GIT binary patch delta 80 zcmZorXi%6CrDp5Hz`*y2fq`KL5Gw&OGGGL9z~U1d)P;>rthp3`ASW{~Rl!!l(3-1u R<3VM QL1n&)7dSRQ;gewm00SHkY5)KL From 7ee63fbc8c134c531e97f842e24d2f70128a55d6 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 4 Apr 2014 11:25:48 +0200 Subject: [PATCH 003/172] Remove temporary file that was added my mistake. --- donation/security/._ir.model.access.csv | Bin 4096 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 donation/security/._ir.model.access.csv diff --git a/donation/security/._ir.model.access.csv b/donation/security/._ir.model.access.csv deleted file mode 100644 index 1d7850f0b1e4c5b30892789b9980da5e959e7895..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmeH~I|>3Z5QaxVL<>8uWEnhw;GX(v5zXo%Xk#tT zz%coT{2}vo1C3r2>HrJIak<6~R#En#6><#Fxr7>Y=L%4Z!udhHRH}|=0!f_%n1+2cKH!*RiOG9MA8dzqsXxh)(QxU()pX}mCATEmn&pb|TeTg6NkHqgrT O)8&2s*C>66ZnrxJJuOQB From f941d86f5839ecfa961b0d6030bcc19ac2d24a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A8re=20Bernard?= Date: Tue, 15 Apr 2014 17:04:38 +0200 Subject: [PATCH 004/172] 1. Renamed fields donator -> donor and donation_ok -> donation 2. Added wizard Generate Mass Journal in mass module 3. Fixed a bug in Stay module room name was empty in tree views --- donation/donation.py | 11 +++++------ donation/donation_view.xml | 4 ++-- donation/i18n/donation.pot | 2 +- donation/i18n/fr.po | 4 ++-- donation/product.py | 6 +++--- donation/product_demo.xml | 2 +- donation/product_view.xml | 6 +++--- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 074d32f8f..a75a30d43 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -72,7 +72,7 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): _get_donation_currency, type='many2one', relation='res.currency', string='Currency'), 'partner_id': fields.many2one( - 'res.partner', 'Donator', required=True, + 'res.partner', 'Donor', required=True, states={'done': [('readonly', True)]}), 'check_total': fields.float( 'Check Amount', digits_compute=dp.get_precision('Account'), @@ -123,9 +123,8 @@ def _get_default_journal(self, cr, uid, context=None): def get_default_campaign(self, cr, uid, context=None): user = self.pool['res.users'].browse(cr, uid, uid, context=context) # here "ids" = uid where uid contains user access rules - return user.context_donation_campaign_id.id - - + return user.context_donation_campaign_id.id + _defaults = { 'state': 'draft', @@ -174,7 +173,7 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): period_id = period_search[0] movelines = [] - # Note : we can have negative donations for donators that use direct + # Note : we can have negative donations for donors that use direct # debit when their direct debit rejected by the bank for donation_line in donation.line_ids: account_id = donation_line.product_id.property_account_income.id @@ -303,7 +302,7 @@ def _compute_amount(self, cr, uid, ids, name, arg, context=None): _columns = { 'donation_id': fields.many2one( 'donation.donation', 'Donation', ondelete='cascade'), - 'product_id': fields.many2one('product.product', 'Product', domain=[('donation_ok', '=', True)]), + 'product_id': fields.many2one('product.product', 'Product', domain=[('donation', '=', True)]), 'quantity': fields.integer('Quantity'), 'unit_price': fields.float( 'Unit Price', digits_compute=dp.get_precision('Account')), diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 29aff6d6c..bd188c70c 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -127,13 +127,13 @@ - Donators + Donors res.partner form kanban,tree,form - + Products diff --git a/donation/i18n/donation.pot b/donation/i18n/donation.pot index c5dd2621f..46fed0e0e 100644 --- a/donation/i18n/donation.pot +++ b/donation/i18n/donation.pot @@ -175,7 +175,7 @@ msgstr "" #. module: donation #: field:donation.donation,partner_id:0 -msgid "Donator" +msgid "Donor" msgstr "" #. module: donation diff --git a/donation/i18n/fr.po b/donation/i18n/fr.po index a2e3b5876..356e64b53 100644 --- a/donation/i18n/fr.po +++ b/donation/i18n/fr.po @@ -175,8 +175,8 @@ msgstr "The amount must be positive or 0." #. module: donation #: field:donation.donation,partner_id:0 -msgid "Donator" -msgstr "Donator" +msgid "Donor" +msgstr "Donor" #. module: donation #: field:donation.donation,currency_id:0 diff --git a/donation/product.py b/donation/product.py index d6505b903..80185b2e1 100644 --- a/donation/product.py +++ b/donation/product.py @@ -26,7 +26,7 @@ class product_template(orm.Model): _inherit = 'product.template' _columns = { - 'donation_ok': fields.boolean( + 'donation': fields.boolean( 'Is a Donation', help="Specify if the product can be selected" "in a donation line."), @@ -36,8 +36,8 @@ class product_template(orm.Model): class product_product(orm.Model): _inherit = 'product.product' - def donation_ok_change(self, cr, uid, ids, donation_ok, context=None): + def donation_change(self, cr, uid, ids, donation, context=None): res = {} - if donation_ok: + if donation: res['value'] = {'type': 'service', 'sale_ok': False} return res diff --git a/donation/product_demo.xml b/donation/product_demo.xml index e8b6695cc..8761a1ed0 100644 --- a/donation/product_demo.xml +++ b/donation/product_demo.xml @@ -7,7 +7,7 @@ Donation 0 - 1 + 1 0 service diff --git a/donation/product_view.xml b/donation/product_view.xml index 2a9f1a982..c6f47dc73 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -9,7 +9,7 @@ - + @@ -20,8 +20,8 @@
- -
From 6c064d2efb7235c307e596505a53dfbfb6259ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A8re=20Bernard?= Date: Wed, 7 May 2014 16:58:05 +0200 Subject: [PATCH 005/172] enhancements of donation move lines : ref and link to partner donation number may be generated in a sequence per user. By default, number is generated in the donation sequence --- donation/donation.py | 35 +++++++++++++++-------------------- donation/donation_data.xml | 4 ++-- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index a75a30d43..1d6c93360 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -41,14 +41,12 @@ class donation_donation(orm.Model): _rec_name = 'number' def _compute_total(self, cr, uid, ids, name, arg, context=None): - print "_compute_total ids=", ids res = {} # key = ID, value : amount_total for donation in self.browse(cr, uid, ids, context=context): total = 0.0 for line in donation.line_ids: total += line.quantity * line.unit_price res[donation.id] = total - print "_compute_total res=", total return res def _get_donation_from_lines(self, cr, uid, ids, context=None): @@ -156,7 +154,7 @@ def _check_donation_date(self, cr, uid, ids): 'A donation with this number already exists for this company' )] - def _prepare_donation_move(self, cr, uid, donation, context=None): + def _prepare_donation_move(self, cr, uid, donation, number, context=None): if context is None: context = {} @@ -194,6 +192,7 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): 'credit': credit, 'debit': debit, 'account_id': account_id, + 'partner_id': donation.partner_id.id, })) # counter-part @@ -209,16 +208,17 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): 'credit': credit, 'name': _('Don de %s') % donation.partner_id.name, 'account_id': donation.journal_id.default_debit_account_id.id, + 'partner_id': donation.partner_id.id, })) vals = { 'journal_id': donation.journal_id.id, 'date': donation.donation_date, 'period_id': period_id, - 'ref': _('Don %s de %s') % (donation.number, donation.partner_id.name), +# 'ref': _('Don %s de %s') % (number, donation.partner_id.name), + 'ref': number, 'line_id': movelines, } - print "_prepare_donation_move vals=", vals return vals def validate(self, cr, uid, ids, context=None): @@ -230,8 +230,6 @@ def validate(self, cr, uid, ids, context=None): _('Error:'), _('Cannot validate a donation without lines!')) - print "donation.check_total=", donation.check_total - print "donation.amount_total=", donation.amount_total if donation.check_total != donation.amount_total: raise orm.except_orm( _('Error:'), @@ -246,19 +244,23 @@ def validate(self, cr, uid, ids, context=None): ) donation_write_vals = {'state': 'done'} + if not donation.number: + sequence = self.pool.get('ir.sequence') + current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + donation_write_vals['number'] = sequence.next_by_code(cr, uid, + 'donation.donation.' + current_user.login, context=context) \ + or sequence.next_by_code(cr, uid, + 'donation.donation', context=context) + if donation.amount_total: move_vals = self._prepare_donation_move( - cr, uid, donation, context=context) + cr, uid, donation, donation_write_vals['number'], context=context) move_id = self.pool['account.move'].create( cr, uid, move_vals, context=context) self.pool['account.move'].post(cr, uid, [move_id], context=context) donation_write_vals['move_id'] = move_id - if not donation.number: - donation_write_vals['number'] = self.pool['ir.sequence'].next_by_code( - cr, uid, 'donation.donation', context=context) - self.write(cr, uid, donation.id, donation_write_vals, context=context) return @@ -361,11 +363,4 @@ class account_journal(orm.Model): "Select 'Donations' for donation journals." ), } - - - - - - - - + \ No newline at end of file diff --git a/donation/donation_data.xml b/donation/donation_data.xml index 6455c2463..21c488b5c 100644 --- a/donation/donation_data.xml +++ b/donation/donation_data.xml @@ -11,8 +11,8 @@ Donation donation.donation - DON-%(year)s- - 4 + DON- + 6 From 2b541bdde5d0cbd942d00677f3949a28a0363300 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 13 May 2014 11:45:57 +0200 Subject: [PATCH 006/172] Add support for analytic accounting in donation and mass. Add support for foreign currencies in donations. Add mass validation wizard (validate mass lines and create account moves) Add conventual information on mass lines. Small usability improvements. --- donation/donation.py | 110 +++++++++++++++++++++++++++++-------- donation/donation_view.xml | 3 + 2 files changed, 91 insertions(+), 22 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 1d6c93360..e78f389e6 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -154,6 +154,12 @@ def _check_donation_date(self, cr, uid, ids): 'A donation with this number already exists for this company' )] + + def _get_analytic_account_id( + self, cr, uid, donation_line, account_id, context=None): + analytic_account_id = donation_line.analytic_account_id.id or False + return analytic_account_id + def _prepare_donation_move(self, cr, uid, donation, number, context=None): if context is None: context = {} @@ -171,9 +177,21 @@ def _prepare_donation_move(self, cr, uid, donation, number, context=None): period_id = period_search[0] movelines = [] + if donation.company_id.currency_id.id != donation.currency_id.id: + currency_id = donation.currency_id.id + else: + currency_id = False + total_amount_currency = 0.0 # Note : we can have negative donations for donors that use direct # debit when their direct debit rejected by the bank + amount_total_company_cur = 0.0 + name = _('Don de %s') % donation.partner_id.name + + aml = {} + # key = (account_id, analytic_account_id) + # value = {'credit': ..., 'debit': ..., 'amount_currency': ...} for donation_line in donation.line_ids: + amount_total_company_cur += donation_line.amount_company_currency account_id = donation_line.product_id.property_account_income.id if not account_id: account_id = donation_line.product_id.categ_id.property_account_income_categ.id @@ -181,41 +199,71 @@ def _prepare_donation_move(self, cr, uid, donation, number, context=None): raise orm.except_orm( _('Error:'), _("Missing income account on product '%s' or on it's related product category") % donation_line.product_id.name) - if donation_line.amount > 0: - credit = donation_line.amount + analytic_account_id = self._get_analytic_account_id( + cr, uid, donation_line, account_id, context=context) + if not currency_id: + amount_currency = 0.0 + if donation_line.amount_company_currency > 0: + credit = donation_line.amount_company_currency debit = 0 + if currency_id: + amount_currency = donation_line.amount * -1 else: - debit = donation_line.amount * -1 + debit = donation_line.amount_company_currency * -1 credit = 0 + if currency_id: + amount_currency = donation_line.amount + + #TODO Take into account the option group_invoice_lines ?? + if (account_id, analytic_account_id) in aml: + aml[(account_id, analytic_account_id)]['credit'] += credit + aml[(account_id, analytic_account_id)]['debit'] += debit + aml[(account_id, analytic_account_id)]['amount_currency'] += amount_currency + else: + aml[(account_id, analytic_account_id)] = { + 'credit': credit, + 'debit': debit, + 'amount_currency': amount_currency, + } + + for (account_id, analytic_account_id), content in aml.iteritems(): movelines.append((0, 0, { - 'name': donation_line.product_id.name, - 'credit': credit, - 'debit': debit, + 'name': name, + 'credit': content['credit'], + 'debit': content['debit'], 'account_id': account_id, + 'analytic_account_id': analytic_account_id, 'partner_id': donation.partner_id.id, + 'currency_id': currency_id, + 'amount_currency': content['amount_currency'], })) # counter-part - if donation.amount_total > 0: - debit = donation.amount_total + if amount_total_company_cur > 0: + debit = amount_total_company_cur credit = 0 + if currency_id: + total_amount_currency = donation.amount_total else: - credit = donation.amount_total * -1 + credit = amount_total_company_cur * -1 debit = 0 + if currency_id: + total_amount_currency = donation.amount_total * -1 movelines.append( (0, 0, { 'debit': debit, 'credit': credit, - 'name': _('Don de %s') % donation.partner_id.name, + 'name': name, 'account_id': donation.journal_id.default_debit_account_id.id, 'partner_id': donation.partner_id.id, + 'currency_id': currency_id, + 'amount_currency': total_amount_currency, })) vals = { 'journal_id': donation.journal_id.id, 'date': donation.donation_date, 'period_id': period_id, -# 'ref': _('Don %s de %s') % (number, donation.partner_id.name), 'ref': number, 'line_id': movelines, } @@ -236,13 +284,6 @@ def validate(self, cr, uid, ids, context=None): _("The amount of the donation (%s) is different from the sum of the donation lines (%s).") % (donation.check_total, donation.amount_total)) - # We only manage donations of the same currency for the moment - if donation.currency_id.id != donation.company_id.currency_id.id: - raise orm.except_orm( - _('Error:'), - _("The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment.") % (donation.currency_id.name, donation.company_id.name, donation.company_id.currency_id.name) - ) - donation_write_vals = {'state': 'done'} if not donation.number: sequence = self.pool.get('ir.sequence') @@ -298,21 +339,46 @@ class donation_line(orm.Model): def _compute_amount(self, cr, uid, ids, name, arg, context=None): res = {} for line in self.browse(cr, uid, ids, context=context): - res[line.id] = line.quantity * line.unit_price + amount = line.quantity * line.unit_price + company_cur_id = line.donation_id.company_id.currency_id.id + donation_cur_id = line.donation_id.currency_id.id + if company_cur_id == donation_cur_id: + amount_company_currency = amount + else: + ctx_convert = context.copy() + ctx_convert['date'] = line.donation_id.donation_date + amount_company_currency = self.pool['res.currency'].compute( + cr, uid, donation_cur_id, company_cur_id, amount, + context=ctx_convert) + res[line.id] = { + 'amount': amount, + 'amount_company_currency': amount_company_currency, + } return res _columns = { 'donation_id': fields.many2one( 'donation.donation', 'Donation', ondelete='cascade'), - 'product_id': fields.many2one('product.product', 'Product', domain=[('donation', '=', True)]), + 'product_id': fields.many2one( + 'product.product', 'Product', required=True, + domain=[('donation', '=', True)]), 'quantity': fields.integer('Quantity'), 'unit_price': fields.float( 'Unit Price', digits_compute=dp.get_precision('Account')), 'amount': fields.function( - _compute_amount, string='Amount', + _compute_amount, multi="donline", type="float", string='Amount', digits_compute=dp.get_precision('Account'), store={ 'donation.line': (lambda self, cr, uid, ids, c={}: ids, ['quantity', 'unit_price'], 10), }), + 'amount_company_currency': fields.function( + _compute_amount, multi="donline", type="float", + string='Amount in Company Currency', + digits_compute=dp.get_precision('Account'), store={ + 'donation.line': (lambda self, cr, uid, ids, c={}: ids, ['quantity', 'unit_price'], 10), + }), + 'analytic_account_id': fields.many2one( + 'account.analytic.account', 'Analytic Account', + domain=[('type', 'not in', ('view', 'template'))]), 'sequence': fields.integer('Sequence'), } @@ -363,4 +429,4 @@ class account_journal(orm.Model): "Select 'Donations' for donation journals." ), } - \ No newline at end of file + diff --git a/donation/donation_view.xml b/donation/donation_view.xml index bd188c70c..d7d77750e 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -80,6 +80,7 @@ + @@ -96,7 +97,9 @@ + + From 8c4d5e4c28df0ebc939057118d6090214800399c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 13 May 2014 14:08:03 +0200 Subject: [PATCH 007/172] Delete mass when putting a donation in back2draft Block deletion of mass line if certains scenarios Fix a bug when re-validating a donation. --- donation/donation.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index e78f389e6..18ded4ed8 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -285,17 +285,19 @@ def validate(self, cr, uid, ids, context=None): % (donation.check_total, donation.amount_total)) donation_write_vals = {'state': 'done'} - if not donation.number: + number = donation.number + if not number: sequence = self.pool.get('ir.sequence') current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - donation_write_vals['number'] = sequence.next_by_code(cr, uid, + number = sequence.next_by_code(cr, uid, 'donation.donation.' + current_user.login, context=context) \ or sequence.next_by_code(cr, uid, 'donation.donation', context=context) + donation_write_vals['number'] = number if donation.amount_total: move_vals = self._prepare_donation_move( - cr, uid, donation, donation_write_vals['number'], context=context) + cr, uid, donation, number, context=context) move_id = self.pool['account.move'].create( cr, uid, move_vals, context=context) From 12e7bb9c0c0279ef5093e196f0110d04802101ac Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 13 May 2014 21:24:27 +0200 Subject: [PATCH 008/172] Add wizard to swap celebrants. Add monetary widget in form views. --- donation/donation.py | 4 +++- donation/donation_view.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 18ded4ed8..1c00b0a67 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -30,7 +30,9 @@ class res_users(orm.Model): _inherit = 'res.users' _columns = { - 'context_donation_campaign_id': fields.many2one('donation.campaign', 'Donation Campaign User'), # begin with context_... + 'context_donation_campaign_id': fields.many2one( + 'donation.campaign', 'Donation Campaign User'), + # begin with context_ to allow user to change it by itself } diff --git a/donation/donation_view.xml b/donation/donation_view.xml index d7d77750e..da3488dce 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -18,7 +18,7 @@ - + From 76dd246b0ab215c7c0dc218e553996c87c5786f1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 14 May 2014 00:25:53 +0200 Subject: [PATCH 009/172] PEP8 updates Add support for account move generation on mass transfer validation Add "Back to draft" on validated mass transfers --- donation/donation.py | 9 ++------- donation/donation_campaign.py | 11 +++++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 1c00b0a67..505b9a3a9 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -289,12 +289,8 @@ def validate(self, cr, uid, ids, context=None): donation_write_vals = {'state': 'done'} number = donation.number if not number: - sequence = self.pool.get('ir.sequence') - current_user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - number = sequence.next_by_code(cr, uid, - 'donation.donation.' + current_user.login, context=context) \ - or sequence.next_by_code(cr, uid, - 'donation.donation', context=context) + number = self.pool['ir.sequence'].next_by_code( + cr, uid, 'donation.donation', context=context) donation_write_vals['number'] = number if donation.amount_total: @@ -331,7 +327,6 @@ def back_to_draft(self, cr, uid, ids, context=None): self.pool['account.move'].unlink( cr, uid, donation.move_id.id, context=context) donation.write({'state': 'draft'}, context=context) - # TODO : does it work if the account.move is reconciled ??? It should not. return diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py index c6c1b3a8a..a390b908e 100644 --- a/donation/donation_campaign.py +++ b/donation/donation_campaign.py @@ -20,8 +20,7 @@ ############################################################################## from openerp.osv import orm, fields -from openerp.tools import DEFAULT_SERVER_DATE_FORMAT -from datetime import datetime + class donation_campaign(orm.Model): _name = 'donation.campaign' @@ -30,11 +29,11 @@ class donation_campaign(orm.Model): _columns = { 'code': fields.char('Code', size=10), 'name': fields.char('Name', size=64, required=True), - 'campaign_creation_date': fields.date('Campaign Creation Date', readonly=True), - 'nota':fields.text('Notes'), + 'campaign_creation_date': fields.date( + 'Campaign Creation Date', readonly=True), + 'nota': fields.text('Notes'), } _defaults = { - 'campaign_creation_date' : fields.date.context_today, - + 'campaign_creation_date': fields.date.context_today, } From b2a318152a452969d5ba8f7225821cb87b1c3b19 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 15 May 2014 21:30:53 +0200 Subject: [PATCH 010/172] Return True to avoid a warning. Small change in account move ref. --- donation/donation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 505b9a3a9..eaa699575 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -303,7 +303,7 @@ def validate(self, cr, uid, ids, context=None): donation_write_vals['move_id'] = move_id self.write(cr, uid, donation.id, donation_write_vals, context=context) - return + return True def copy(self, cr, uid, id, default=None, context=None): if default is None: @@ -327,7 +327,7 @@ def back_to_draft(self, cr, uid, ids, context=None): self.pool['account.move'].unlink( cr, uid, donation.move_id.id, context=context) donation.write({'state': 'draft'}, context=context) - return + return True class donation_line(orm.Model): @@ -428,4 +428,3 @@ class account_journal(orm.Model): "Select 'Donations' for donation journals." ), } - From 0777ff7ae1fcd2ee06c42f8a1a1981122132f741 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 16 May 2014 08:23:47 +0200 Subject: [PATCH 011/172] Fix for duplication of a partner (inherit of copy() was needed) --- donation/donation.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/donation/donation.py b/donation/donation.py index eaa699575..c73449704 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -402,6 +402,15 @@ class res_partner(orm.Model): 'donation.donation', 'partner_id', 'Donations'), } + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} + default.update({ + 'donation_ids': False, + }) + return super(res_partner, self).copy( + cr, uid, id, default=default, context=context) + class account_journal(orm.Model): _inherit = 'account.journal' From e8738aae28f2b76c578423d4565f64426386f64b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 16 May 2014 14:31:49 +0200 Subject: [PATCH 012/172] Add title in partner_name on stay Donors are res.parter with customer = True --- donation/donation_view.xml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index da3488dce..4f998bcd8 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -15,7 +15,9 @@ - + @@ -129,14 +131,7 @@ - - Donors - res.partner - form - kanban,tree,form - - - + Products From 9a1a46ad2a72d8d62d38cd7ed3f95fd507a80ab7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 00:02:07 +0200 Subject: [PATCH 013/172] Add graph views and group_by in search view for BI Add field amount_total_company_currency on donation.donation Remove view_type from action definition --- donation/donation.py | 32 +++++++++++++++++++++++------ donation/donation_campaign_view.xml | 1 - donation/donation_view.xml | 19 ++++++++++++----- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index c73449704..792acccdc 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -43,12 +43,26 @@ class donation_donation(orm.Model): _rec_name = 'number' def _compute_total(self, cr, uid, ids, name, arg, context=None): + if context is None: + context = {} res = {} # key = ID, value : amount_total for donation in self.browse(cr, uid, ids, context=context): total = 0.0 for line in donation.line_ids: total += line.quantity * line.unit_price - res[donation.id] = total + if donation.currency_id == donation.company_id.currency_id: + total_company_currency = total + else: + ctx_convert = context.copy() + ctx_convert['date'] = donation.donation_date + total_company_currency = self.pool['res.currency'].compute( + cr, uid, donation.currency_id.id, + donation.company_id.currency_id.id, total, + context=ctx_convert) + res[donation.id] = { + 'amount_total': total, + 'amount_total_company_currency': total_company_currency, + } return res def _get_donation_from_lines(self, cr, uid, ids, context=None): @@ -78,9 +92,16 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): 'Check Amount', digits_compute=dp.get_precision('Account'), states={'done': [('readonly', True)]}), 'amount_total': fields.function( - _compute_total, type='float', string='Amount Total', store={ + _compute_total, type='float', multi="donation", + string='Amount Total', store={ 'donation.line': (_get_donation_from_lines, ['unit_price', 'quantity', 'donation_id'], 10), }), + 'amount_total_company_currency': fields.function( + _compute_total, type='float', multi="donation", + string='Amount Total in Company Currency', store={ + 'donation.donation': (lambda self, cr, uid, ids, c={}: ids, ['currency_id', 'journal_id'], 10), + 'donation.line': (_get_donation_from_lines, ['unit_price', 'quantity', 'donation_id'], 20), + }), 'donation_date': fields.date( 'Donation Date', required=True, states={'done': [('readonly', True)]}), @@ -120,12 +141,11 @@ def _get_default_journal(self, cr, uid, context=None): (model, res_id) = self.pool['ir.model.data'].get_object_reference(cr, uid, 'donation', 'donation_journal') assert model == 'account.journal', 'Wrong model' return res_id - + def get_default_campaign(self, cr, uid, context=None): user = self.pool['res.users'].browse(cr, uid, uid, context=context) # here "ids" = uid where uid contains user access rules - return user.context_donation_campaign_id.id - - + return user.context_donation_campaign_id.id + _defaults = { 'state': 'draft', 'company_id': lambda self, cr, uid, context: \ diff --git a/donation/donation_campaign_view.xml b/donation/donation_campaign_view.xml index d2b161666..da2d7fb74 100644 --- a/donation/donation_campaign_view.xml +++ b/donation/donation_campaign_view.xml @@ -41,7 +41,6 @@ Campaign of Donations donation.campaign - form tree,form diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 4f998bcd8..a5f8dc180 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -66,6 +66,7 @@ + @@ -73,6 +74,18 @@ + + + donation.graph + donation.donation + + + + + + + + donation.line.tree donation.line @@ -108,18 +121,15 @@ - Donations donation.donation - form - tree,form + tree,form,graph Donations Lines donation.line - form tree,form @@ -137,7 +147,6 @@ Products product.product kanban,tree,form - form {'search_default_filter_to_donation': 1} From 9a96f500ff74bb086f7c3d7e1605e876c3064e88 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 11:18:32 +0200 Subject: [PATCH 014/172] Add donation count on partner form Update icon Update comments --- donation/__openerp__.py | 1 + donation/donation.py | 13 +++++++++++++ donation/partner_view.xml | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 donation/partner_view.xml diff --git a/donation/__openerp__.py b/donation/__openerp__.py index 3c07c25cc..ed1d64e5f 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -45,6 +45,7 @@ 'donation_campaign_view.xml', 'campaign_user_view.xml', 'security/ir.model.access.csv', + 'partner_view.xml', ], 'demo': [ 'product_demo.xml', diff --git a/donation/donation.py b/donation/donation.py index 792acccdc..47a0ddd5a 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -417,9 +417,22 @@ def product_id_change(self, cr, uid, ids, product_id, context): class res_partner(orm.Model): _inherit = 'res.partner' + + def _donation_count(self, cr, uid, ids, field_name, arg, context=None): + res = dict(map(lambda x: (x, 0), ids)) + # The current user may not have access rights for donations + try: + for partner in self.browse(cr, uid, ids, context): + res[partner.id] = len(partner.donation_ids) + except: + pass + return res + _columns = { 'donation_ids': fields.one2many( 'donation.donation', 'partner_id', 'Donations'), + 'donation_count': fields.function( + _donation_count, string="# of Donations", type='integer'), } def copy(self, cr, uid, id, default=None, context=None): diff --git a/donation/partner_view.xml b/donation/partner_view.xml new file mode 100644 index 000000000..bedaef491 --- /dev/null +++ b/donation/partner_view.xml @@ -0,0 +1,39 @@ + + + + + + + + + Donations + donation.donation + tree,form,graph + {'search_default_partner_id': active_id} + + + + + donation.button.res.partner.form + res.partner + + + + + + + + + + + From 3df7e631b30574cca2780fade09a82569750f58b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 14:41:06 +0200 Subject: [PATCH 015/172] Add ir.rule for multi-company for donation, tax receipts and mass. --- donation/security/donation_security.xml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/donation/security/donation_security.xml b/donation/security/donation_security.xml index 364611150..cbb7f4663 100644 --- a/donation/security/donation_security.xml +++ b/donation/security/donation_security.xml @@ -1,7 +1,14 @@ + + - + Donation @@ -21,5 +28,17 @@ + + + + + + + Donation Multi-company + + + ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + From 69cd45c090458517949a9909de66eab33525c6c7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 15:21:15 +0200 Subject: [PATCH 016/172] Add sheet tags to have the statusbar on the right. --- donation/donation_view.xml | 53 ++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index a5f8dc180..9c5bb80e0 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -9,32 +9,41 @@
-
- - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - + + - - - - + From ae3aa62e09b85b1e1b0232eb1bb6a9b51a52d1e0 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 17:37:51 +0200 Subject: [PATCH 017/172] Small improvements to donation campaigns --- donation/campaign_user_view.xml | 25 +++++++++++++------------ donation/donation.py | 2 +- donation/donation_campaign.py | 17 ++++++++++++++--- donation/donation_campaign_view.xml | 19 +++++++++---------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/donation/campaign_user_view.xml b/donation/campaign_user_view.xml index aee63d3fb..a38006232 100644 --- a/donation/campaign_user_view.xml +++ b/donation/campaign_user_view.xml @@ -4,24 +4,25 @@ - donation.res.users.form - res.users - - - - - - + donation.res.users.form + res.users + + + + + + - donation.preferences.res.users.form + donation.preferences.res.users.form res.users - - - + + + diff --git a/donation/donation.py b/donation/donation.py index 47a0ddd5a..6c6e16370 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -31,7 +31,7 @@ class res_users(orm.Model): _columns = { 'context_donation_campaign_id': fields.many2one( - 'donation.campaign', 'Donation Campaign User'), + 'donation.campaign', 'Current Donation Campaign'), # begin with context_ to allow user to change it by itself } diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py index a390b908e..4a850c9e0 100644 --- a/donation/donation_campaign.py +++ b/donation/donation_campaign.py @@ -25,15 +25,26 @@ class donation_campaign(orm.Model): _name = 'donation.campaign' _description = 'Code attributed for a Donation Campaign' + _order = 'code' + + def name_get(self, cr, uid, ids, context=None): + res = [] + if isinstance(ids, (int, long)): + ids = [ids] + for record in self.browse(cr, uid, ids, context=context): + if record.code: + res.append((record.id, u'[%s] %s' % (record.code, record.name))) + else: + res.append((record.id, record.name)) + return res _columns = { 'code': fields.char('Code', size=10), 'name': fields.char('Name', size=64, required=True), - 'campaign_creation_date': fields.date( - 'Campaign Creation Date', readonly=True), + 'start_date': fields.date('Start Date'), 'nota': fields.text('Notes'), } _defaults = { - 'campaign_creation_date': fields.date.context_today, + 'start_date': fields.date.context_today, } diff --git a/donation/donation_campaign_view.xml b/donation/donation_campaign_view.xml index da2d7fb74..aad9f3d2e 100644 --- a/donation/donation_campaign_view.xml +++ b/donation/donation_campaign_view.xml @@ -13,14 +13,12 @@ donation.campaign.form donation.campaign -
+ - - - - + +
@@ -30,21 +28,22 @@ donation.campaign.tree donation.campaign - - + - + + - Campaign of Donations + Donation Campaigns donation.campaign tree,form - +
From 1c7ffab767c54158b295c33fd907e848dfa4bf36 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 18:26:05 +0200 Subject: [PATCH 018/172] Rename method to respect coding conventions. --- donation/donation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 6c6e16370..eac19fff4 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -142,8 +142,8 @@ def _get_default_journal(self, cr, uid, context=None): assert model == 'account.journal', 'Wrong model' return res_id - def get_default_campaign(self, cr, uid, context=None): - user = self.pool['res.users'].browse(cr, uid, uid, context=context) # here "ids" = uid where uid contains user access rules + def _get_default_campaign(self, cr, uid, context=None): + user = self.pool['res.users'].browse(cr, uid, uid, context=context) return user.context_donation_campaign_id.id _defaults = { @@ -153,7 +153,7 @@ def get_default_campaign(self, cr, uid, context=None): cr, uid, 'donation.donation', context=context), 'currency_id': _get_default_currency, 'journal_id': _get_default_journal, - 'donation_campaign_id': get_default_campaign, + 'donation_campaign_id': _get_default_campaign, } def _check_donation_date(self, cr, uid, ids): From b3e846a313e609f2646006fdeef1337d7f2b4580 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 13 Jun 2014 23:41:02 +0200 Subject: [PATCH 019/172] Rename field donation_campaign_id to campaign_id FIX invalidation of field 'Amount in Company Currency' on donation.line Add reporting menu for donations --- donation/__init__.py | 2 +- donation/__openerp__.py | 1 + donation/donation.py | 10 ++- donation/donation_view.xml | 6 +- donation/report/__init__.py | 22 ++++++ donation/report/donation_report.py | 92 ++++++++++++++++++++++++ donation/report/donation_report_view.xml | 48 +++++++++++++ donation/security/ir.model.access.csv | 1 + 8 files changed, 175 insertions(+), 7 deletions(-) create mode 100644 donation/report/__init__.py create mode 100644 donation/report/donation_report.py create mode 100644 donation/report/donation_report_view.xml diff --git a/donation/__init__.py b/donation/__init__.py index 20ca7d841..142385ad8 100644 --- a/donation/__init__.py +++ b/donation/__init__.py @@ -22,4 +22,4 @@ from . import donation_campaign from . import donation from . import product - +from . import report diff --git a/donation/__openerp__.py b/donation/__openerp__.py index ed1d64e5f..f000fd553 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -46,6 +46,7 @@ 'campaign_user_view.xml', 'security/ir.model.access.csv', 'partner_view.xml', + 'report/donation_report_view.xml', ], 'demo': [ 'product_demo.xml', diff --git a/donation/donation.py b/donation/donation.py index eac19fff4..c9a85cb9e 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -124,8 +124,7 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): 'company_currency_id': fields.related( 'company_id', 'currency_id', type='many2one', relation="res.currency", string="Company Currency"), - #'origin_id': fields.many2one('donation.origin', 'Origin of Donation'), - 'donation_campaign_id': fields.many2one( + 'campaign_id': fields.many2one( 'donation.campaign', 'Donation Campaign'), 'create_uid': fields.many2one('res.users', 'Created by'), } @@ -153,7 +152,7 @@ def _get_default_campaign(self, cr, uid, context=None): cr, uid, 'donation.donation', context=context), 'currency_id': _get_default_currency, 'journal_id': _get_default_journal, - 'donation_campaign_id': _get_default_campaign, + 'campaign_id': _get_default_campaign, } def _check_donation_date(self, cr, uid, ids): @@ -375,6 +374,10 @@ def _compute_amount(self, cr, uid, ids, name, arg, context=None): } return res + def _get_lines_from_donation(self, cr, uid, ids, context=None): + return self.pool['donation.line'].search( + cr, uid, [('donation_id', 'in', ids)], context=context) + _columns = { 'donation_id': fields.many2one( 'donation.donation', 'Donation', ondelete='cascade'), @@ -394,6 +397,7 @@ def _compute_amount(self, cr, uid, ids, name, arg, context=None): string='Amount in Company Currency', digits_compute=dp.get_precision('Account'), store={ 'donation.line': (lambda self, cr, uid, ids, c={}: ids, ['quantity', 'unit_price'], 10), + 'donation.donation': (_get_lines_from_donation, ['journal_id', 'currency_id'], 10), }), 'analytic_account_id': fields.many2one( 'account.analytic.account', 'Analytic Account', diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 9c5bb80e0..3ab288b21 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -27,7 +27,7 @@ - +
@@ -58,7 +58,7 @@ - + @@ -77,7 +77,7 @@ - + diff --git a/donation/report/__init__.py b/donation/report/__init__.py new file mode 100644 index 000000000..012507d69 --- /dev/null +++ b/donation/report/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Barroux Abbey +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import donation_report diff --git a/donation/report/donation_report.py b/donation/report/donation_report.py new file mode 100644 index 000000000..5a30185c2 --- /dev/null +++ b/donation/report/donation_report.py @@ -0,0 +1,92 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for OpenERP +# Copyright (C) 2014 Barroux Abbey +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import tools +from openerp.osv import orm, fields + + +class donation_report(orm.Model): + _name = "donation.report" + _description = "Donations Analysis" + _auto = False + _rec_name = 'donation_date' + _order = "donation_date desc" + + _columns = { + 'donation_date': fields.date('Donation Date', readonly=True), + 'product_id': fields.many2one( + 'product.product', 'Product', readonly=True), + 'partner_id': fields.many2one('res.partner', 'Donor', readonly=True), + 'company_id': fields.many2one('res.company', 'Company', readonly=True), + 'product_categ_id': fields.many2one( + 'product.category', 'Category of Product', readonly=True), + 'campaign_id': fields.many2one( + 'donation.campaign', 'Donation Campaign', readonly=True), + 'amount_company_currency': fields.float( + 'Amount Company Currency', readonly=True), + } + + def _select(self): + select = """ + SELECT min(l.id) AS id, + d.donation_date AS donation_date, + l.product_id AS product_id, + pt.categ_id AS product_categ_id, + d.company_id AS company_id, + d.partner_id AS partner_id, + d.campaign_id AS campaign_id, + sum(l.amount_company_currency) AS amount_company_currency + """ + return select + + def _from(self): + from_sql = """ + donation_line l + LEFT JOIN donation_donation d ON (d.id=l.donation_id) + LEFT JOIN product_product pp ON (l.product_id=pp.id) + LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) + """ + return from_sql + + def _where(self): + where = """ + WHERE d.state='done' + """ + return where + + def _group_by(self): + group_by = """ + GROUP BY l.product_id, + pt.categ_id, + d.donation_date, + d.partner_id, + d.campaign_id, + d.company_id + """ + return group_by + + def init(self, cr): + tools.drop_view_if_exists(cr, self._table) + cr.execute( + """CREATE OR REPLACE VIEW %s AS ( + %s FROM %s %s %s)""" % ( + self._table, self._select(), self._from(), + self._where(), self._group_by())) diff --git a/donation/report/donation_report_view.xml b/donation/report/donation_report_view.xml new file mode 100644 index 000000000..aeafa36ce --- /dev/null +++ b/donation/report/donation_report_view.xml @@ -0,0 +1,48 @@ + + + + + + + donation.report.search + donation.report + + + + + + + + + + + + + + + + + donation.report.graph + donation.report + + + + + + + + + + Donations Analysis + donation.report + graph + + + + + + + + diff --git a/donation/security/ir.model.access.csv b/donation/security/ir.model.access.csv index 48adc27de..a7339e9ff 100644 --- a/donation/security/ir.model.access.csv +++ b/donation/security/ir.model.access.csv @@ -10,3 +10,4 @@ access_account_journal_donation,Read access on account.journal,account.model_acc access_account_journal_period_donation,Full access on account.journal.period,account.model_account_journal_period,group_donation_user,1,1,1,1 access_account_move_donation,Full access on account.move,account.model_account_move,group_donation_user,1,1,1,1 access_account_move_line_donation,Full access on account.move.line,account.model_account_move_line,group_donation_user,1,1,1,1 +access_donation_report,Full access on donation.report to Donation User,model_donation_report,group_donation_user,1,1,1,1 From f24bdb17733449cc38057f58f6b811fe60bfda77 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 14 Jun 2014 14:50:12 +0200 Subject: [PATCH 020/172] Handle multi-company in default journal selection. --- donation/donation.py | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index c9a85cb9e..048326a79 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -129,31 +129,20 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): 'create_uid': fields.many2one('res.users', 'Created by'), } - def _get_default_currency(self, cr, uid, context=None): - company_id = self.pool['res.company']._company_default_get( - cr, uid, 'donation.donation', context=context) - company = self.pool['res.company'].browse( - cr, uid, company_id, context=context) - return company.currency_id.id - - def _get_default_journal(self, cr, uid, context=None): - (model, res_id) = self.pool['ir.model.data'].get_object_reference(cr, uid, 'donation', 'donation_journal') - assert model == 'account.journal', 'Wrong model' - return res_id - - def _get_default_campaign(self, cr, uid, context=None): + def default_get(self, cr, uid, fields_list, context=None): + res = {'state': 'draft'} user = self.pool['res.users'].browse(cr, uid, uid, context=context) - return user.context_donation_campaign_id.id - - _defaults = { - 'state': 'draft', - 'company_id': lambda self, cr, uid, context: \ - self.pool['res.company']._company_default_get( - cr, uid, 'donation.donation', context=context), - 'currency_id': _get_default_currency, - 'journal_id': _get_default_journal, - 'campaign_id': _get_default_campaign, - } + res['company_id'] = self.pool['res.company']._company_default_get( + cr, uid, 'donation.donation', context=context) + journal_ids = self.pool['account.journal'].search( + cr, uid, [ + ('company_id', '=', res['company_id']), + ('type', '=', 'donation'), + ], context=context) + if journal_ids: # Take first donation journal + res['journal_id'] = journal_ids[0] + res['campaign_id'] = user.context_donation_campaign_id.id or False + return res def _check_donation_date(self, cr, uid, ids): today_dt = datetime.today() From e6c3b7843c64e9a4685946f2ddf0b3902f4ea50c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 14 Jun 2014 15:19:19 +0200 Subject: [PATCH 021/172] Donation number is the sequence of the account.move (same as with invoices, cf account module) --- donation/donation.py | 26 +++++++------------------- donation/donation_data.xml | 9 +++------ 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 048326a79..97df83bb9 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -39,7 +39,7 @@ class res_users(orm.Model): class donation_donation(orm.Model): _name = 'donation.donation' _description = 'Donations' - _order = 'id desc' + _order = 'number desc, id desc' _rec_name = 'number' def _compute_total(self, cr, uid, ids, name, arg, context=None): @@ -80,8 +80,6 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): return res _columns = { - 'number': fields.char( - 'Donation Number', size=32, readonly=True), 'currency_id': fields.function( _get_donation_currency, type='many2one', relation='res.currency', string='Currency'), @@ -113,6 +111,9 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): states={'done': [('readonly', True)]}), 'move_id': fields.many2one( 'account.move', 'Account Move', readonly=True), + 'number': fields.related( + 'move_id', 'name', type='char', readonly=True, size=64, + relation='account.move', store=True, string='Donation Number'), 'journal_id': fields.many2one( 'account.journal', 'Payment Method', required=True, domain=[('type', '=', 'donation')], @@ -158,19 +159,12 @@ def _check_donation_date(self, cr, uid, ids): ['donation_date'] )] - _sql_constraints = [( - 'number_company_unique', - 'unique(company_id, number)', - 'A donation with this number already exists for this company' - )] - - def _get_analytic_account_id( self, cr, uid, donation_line, account_id, context=None): analytic_account_id = donation_line.analytic_account_id.id or False return analytic_account_id - def _prepare_donation_move(self, cr, uid, donation, number, context=None): + def _prepare_donation_move(self, cr, uid, donation, context=None): if context is None: context = {} @@ -274,7 +268,7 @@ def _prepare_donation_move(self, cr, uid, donation, number, context=None): 'journal_id': donation.journal_id.id, 'date': donation.donation_date, 'period_id': period_id, - 'ref': number, + 'ref': False, # TODO 'line_id': movelines, } return vals @@ -295,15 +289,10 @@ def validate(self, cr, uid, ids, context=None): % (donation.check_total, donation.amount_total)) donation_write_vals = {'state': 'done'} - number = donation.number - if not number: - number = self.pool['ir.sequence'].next_by_code( - cr, uid, 'donation.donation', context=context) - donation_write_vals['number'] = number if donation.amount_total: move_vals = self._prepare_donation_move( - cr, uid, donation, number, context=context) + cr, uid, donation, context=context) move_id = self.pool['account.move'].create( cr, uid, move_vals, context=context) @@ -318,7 +307,6 @@ def copy(self, cr, uid, id, default=None, context=None): default = {} default['state'] = 'draft' default['move_id'] = False - default['number'] = False res = super(donation_donation, self).copy( cr, uid, id, default=default, context=context) return res diff --git a/donation/donation_data.xml b/donation/donation_data.xml index 21c488b5c..f96f9e173 100644 --- a/donation/donation_data.xml +++ b/donation/donation_data.xml @@ -3,23 +3,20 @@ - - Donation Number - donation.donation - - Donation donation.donation DON- 6 - + Donation Journal DON donation + + From 2e2768f8197a8be3a9e7f2b13e5479b7f64b2dbb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 14 Jun 2014 15:27:46 +0200 Subject: [PATCH 022/172] Remove code from journal (sequence for journals don't have a seq type) --- donation/donation_data.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/donation/donation_data.xml b/donation/donation_data.xml index f96f9e173..60ec16152 100644 --- a/donation/donation_data.xml +++ b/donation/donation_data.xml @@ -4,8 +4,7 @@ - Donation - donation.donation + Account Donation Journal DON- 6 From 7c76e89a7ddb59b022e914e0f2f7615aa7c940fe Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 14 Jun 2014 23:12:00 +0200 Subject: [PATCH 023/172] Add demo data for mass requests Update mass prices Add graph view for mass requests --- donation/donation_view.xml | 2 +- donation/report/donation_report_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 3ab288b21..cdaeb507b 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -74,7 +74,7 @@ - + diff --git a/donation/report/donation_report_view.xml b/donation/report/donation_report_view.xml index aeafa36ce..74cad4dce 100644 --- a/donation/report/donation_report_view.xml +++ b/donation/report/donation_report_view.xml @@ -8,7 +8,7 @@ donation.report - + From eb5cb45aec475ceff4fe2332c6cced5c3e951517 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 3 Jul 2014 11:02:10 +0200 Subject: [PATCH 024/172] =?UTF-8?q?Multiple=20small=20enhancements=20Add?= =?UTF-8?q?=20constraints=20on=20room=20in=20stay=20module=20Add=20French?= =?UTF-8?q?=20translation=20by=20Brother=20Ir=C3=A9n=C3=A9e=20Move=20donat?= =?UTF-8?q?ion=5Fdata.xml=20to=20donation=5Fdemo.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- donation/__openerp__.py | 1 - donation/donation_data.xml | 22 --- donation/donation_demo.xml | 17 ++ donation/donation_view.xml | 3 +- donation/i18n/donation.pot | 302 ++++++++++++++++++++++-------- donation/i18n/fr.po | 370 +++++++++++++++++++++++++------------ donation/product.py | 2 +- 7 files changed, 495 insertions(+), 222 deletions(-) delete mode 100644 donation/donation_data.xml diff --git a/donation/__openerp__.py b/donation/__openerp__.py index f000fd553..0262a5516 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -40,7 +40,6 @@ 'data': [ 'security/donation_security.xml', 'donation_view.xml', - 'donation_data.xml', 'product_view.xml', 'donation_campaign_view.xml', 'campaign_user_view.xml', diff --git a/donation/donation_data.xml b/donation/donation_data.xml deleted file mode 100644 index 60ec16152..000000000 --- a/donation/donation_data.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Account Donation Journal - DON- - 6 - - - - - Donation Journal - DON - donation - - - - - - diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 9243161d6..368cd167f 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -3,12 +3,29 @@ + + Account Donation Journal + DON/ + 6 + + + + + Donation Journal + DON + donation + + + + Quest + Prospecting + Catalog diff --git a/donation/donation_view.xml b/donation/donation_view.xml index cdaeb507b..795fb5d86 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -31,12 +31,11 @@ - + - diff --git a/donation/i18n/donation.pot b/donation/i18n/donation.pot index 46fed0e0e..870fd5511 100644 --- a/donation/i18n/donation.pot +++ b/donation/i18n/donation.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: OpenERP Server 8.0alpha1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-03-13 08:50+0000\n" -"PO-Revision-Date: 2014-03-13 08:50+0000\n" +"POT-Creation-Date: 2014-07-01 12:46+0000\n" +"PO-Revision-Date: 2014-07-01 12:46+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,52 +16,85 @@ msgstr "" "Plural-Forms: \n" #. module: donation -#: code:addons/donation/donation.py:227 -#, python-format -msgid "Missing price on product" +#: field:res.partner,donation_count:0 +msgid "# of Donations" msgstr "" #. module: donation -#: field:donation.donation,state:0 -msgid "State" +#: field:res.partner,stay_count:0 +msgid "# of Stays" msgstr "" #. module: donation -#: selection:donation.donation,state:0 -msgid "Draft" +#: field:donation.donation,move_id:0 +msgid "Account Move" msgstr "" #. module: donation -#: view:donation.line:0 -msgid "Donation Line" +#: field:donation.line,amount:0 +msgid "Amount" msgstr "" #. module: donation -#: field:donation.line,product_id:0 -msgid "Product" +#: field:donation.report,amount_company_currency:0 +msgid "Amount Company Currency" msgstr "" #. module: donation -#: code:addons/donation/donation.py:135 -#, python-format -msgid "The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment." +#: field:donation.donation,amount_total:0 +msgid "Amount Total" msgstr "" #. module: donation -#: field:donation.donation,company_id:0 -msgid "Company" +#: field:donation.donation,amount_total_company_currency:0 +msgid "Amount Total in Company Currency" +msgstr "" + +#. module: donation +#: field:donation.line,amount_company_currency:0 +msgid "Amount in Company Currency" +msgstr "" + +#. module: donation +#: field:donation.line,analytic_account_id:0 +msgid "Analytic Account" msgstr "" #. module: donation #: view:donation.donation:0 -#: field:donation.line,donation_id:0 -#: model:res.groups,name:donation.group_donation -msgid "Donation" +msgid "Back to Draft" msgstr "" #. module: donation -#: constraint:donation.donation:0 -msgid "Date must be today or in the past" +#: view:donation.donation:0 +msgid "Campaign" +msgstr "" + +#. module: donation +#: field:donation.report,product_categ_id:0 +msgid "Category of Product" +msgstr "" + +#. module: donation +#: field:donation.donation,check_total:0 +msgid "Check Amount" +msgstr "" + +#. module: donation +#: field:donation.campaign,code:0 +msgid "Code" +msgstr "" + +#. module: donation +#: model:ir.model,name:donation.model_donation_campaign +msgid "Code attributed for a Donation Campaign" +msgstr "" + +#. module: donation +#: field:donation.donation,company_id:0 +#: view:donation.report:0 +#: field:donation.report,company_id:0 +msgid "Company" msgstr "" #. module: donation @@ -70,142 +103,255 @@ msgid "Company Currency" msgstr "" #. module: donation -#: field:donation.donation,line_ids:0 -#: model:ir.model,name:donation.model_donation_line -msgid "Donation Lines" +#: model:ir.ui.menu,name:donation.donation_config_menu +msgid "Configuration" msgstr "" #. module: donation -#: field:donation.donation,donation_date:0 -msgid "Donation Date" +#: field:donation.donation,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: donation +#: field:donation.donation,currency_id:0 +msgid "Currency" +msgstr "" + +#. module: donation +#: field:res.users,context_donation_campaign_id:0 +msgid "Current Donation Campaign" msgstr "" #. module: donation #: view:donation.donation:0 -msgid "Validate" +#: view:donation.report:0 +msgid "Date" msgstr "" #. module: donation -#: code:addons/donation/donation.py:228 -#, python-format -msgid "The sale price on product '%s' is 0!" +#: constraint:donation.donation:0 +msgid "Date must be today or in the past" msgstr "" #. module: donation -#: field:donation.donation,partner_categ_id:0 -msgid "Categories" +#: view:donation.donation:0 +#: field:donation.line,donation_id:0 +#: model:ir.module.category,name:donation.module_category_donation +#: view:product.product:0 +msgid "Donation" msgstr "" #. module: donation -#: sql_constraint:donation.donation:0 -msgid "A donation with this number already exists for this company" +#: view:donation.campaign:0 +#: field:donation.donation,campaign_id:0 +#: view:donation.report:0 +#: field:donation.report,campaign_id:0 +msgid "Donation Campaign" msgstr "" #. module: donation -#: field:donation.donation,number:0 -msgid "Donation Number" +#: view:donation.campaign:0 +#: model:ir.actions.act_window,name:donation.donation_campaign_action +#: model:ir.ui.menu,name:donation.donation_campaign_menu +msgid "Donation Campaigns" msgstr "" #. module: donation -#: code:addons/donation/donation.py:134 -#: code:addons/donation/donation.py:153 -#, python-format -msgid "Error:" +#: field:donation.donation,donation_date:0 +#: field:donation.report,donation_date:0 +msgid "Donation Date" msgstr "" #. module: donation -#: model:ir.model,name:donation.model_res_company -msgid "Companies" +#: view:donation.line:0 +msgid "Donation Line" msgstr "" #. module: donation -#: field:donation.donation,company_email:0 -msgid "Company Email" +#: field:donation.donation,line_ids:0 +#: model:ir.model,name:donation.model_donation_line +msgid "Donation Lines" msgstr "" #. module: donation -#: field:donation.line,amount:0 -msgid "Amount" +#: field:donation.donation,number:0 +msgid "Donation Number" msgstr "" #. module: donation +#: view:donation.donation:0 #: model:ir.actions.act_window,name:donation.donation_action +#: model:ir.actions.act_window,name:donation.partner_donation_action #: model:ir.model,name:donation.model_donation_donation #: model:ir.ui.menu,name:donation.donation_menu +#: model:ir.ui.menu,name:donation.donation_report_title_menu #: model:ir.ui.menu,name:donation.donation_title_menu -#: view:res.company:0 +#: model:ir.ui.menu,name:donation.donation_top_menu +#: view:res.partner:0 +#: field:res.partner,donation_ids:0 msgid "Donations" msgstr "" #. module: donation +#: view:donation.report:0 +#: model:ir.actions.act_window,name:donation.donation_report_action +#: model:ir.model,name:donation.model_donation_report +#: model:ir.ui.menu,name:donation.donation_report_menu +msgid "Donations Analysis" +msgstr "" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_line_action +msgid "Donations Lines" +msgstr "" + +#. module: donation +#: view:donation.donation:0 #: selection:donation.donation,state:0 -msgid "Waiting Currency Conversion" +msgid "Done" msgstr "" #. module: donation -#: field:donation.donation,move_id:0 -msgid "Account Move" +#: field:donation.donation,partner_id:0 +#: field:donation.report,partner_id:0 +msgid "Donor" msgstr "" #. module: donation -#: field:donation.donation,check_total:0 -msgid "Check Amount" +#: model:ir.ui.menu,name:donation.donor +msgid "Donors" msgstr "" #. module: donation -#: field:res.company,donation_bank_account_id:0 -msgid "Bank Account for Donations" +#: model:product.category,name:donation.product_category_donation +msgid "Dons" msgstr "" #. module: donation -#: code:addons/donation/donation.py:154 -#, python-format -msgid "Missing income account on product '%s' or on it's related product category" +#: view:donation.donation:0 +#: selection:donation.donation,state:0 +msgid "Draft" msgstr "" #. module: donation -#: field:donation.line,sequence:0 -msgid "Sequence" +#: view:donation.donation:0 +#: view:donation.report:0 +msgid "Group By" msgstr "" #. module: donation -#: sql_constraint:donation.line:0 -msgid "The amount must be positive or 0." +#: field:product.template,donation:0 +msgid "Is a Donation" msgstr "" #. module: donation -#: field:donation.donation,partner_id:0 -msgid "Donor" +#: model:ir.model,name:donation.model_account_journal +msgid "Journal" msgstr "" #. module: donation -#: field:donation.donation,currency_id:0 -msgid "Currency" +#: model:ir.module.category,description:donation.module_category_donation +msgid "Manage donations" msgstr "" #. module: donation -#: selection:donation.donation,state:0 -msgid "Done" +#: model:res.groups,name:donation.group_donation_manager +msgid "Manager" msgstr "" #. module: donation -#: model:ir.model,name:donation.model_account_invoice -msgid "Invoice" +#: field:donation.campaign,name:0 +msgid "Name" msgstr "" #. module: donation -#: model:ir.actions.act_window,name:donation.donation_line_action -#: model:ir.ui.menu,name:donation.donation_line_menu -msgid "Donations Lines" +#: field:donation.campaign,nota:0 +msgid "Notes" +msgstr "" + +#. module: donation +#: view:donation.donation:0 +#: view:donation.report:0 +#: model:ir.model,name:donation.model_res_partner +msgid "Partner" msgstr "" #. module: donation #: field:donation.donation,journal_id:0 -msgid "Journal" +msgid "Payment Method" msgstr "" #. module: donation -#: field:donation.donation,amount_total:0 -msgid "Amount Total" +#: field:donation.line,product_id:0 +#: view:donation.report:0 +#: field:donation.report,product_id:0 +#: model:ir.model,name:donation.model_product_product +msgid "Product" +msgstr "" + +#. module: donation +#: view:donation.report:0 +msgid "Product Category" +msgstr "" + +#. module: donation +#: model:ir.model,name:donation.model_product_template +msgid "Product Template" +msgstr "" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_product_action +#: model:ir.ui.menu,name:donation.donation_products +msgid "Products" +msgstr "" + +#. module: donation +#: field:donation.line,quantity:0 +msgid "Quantity" +msgstr "" + +#. module: donation +#: view:donation.donation:0 +msgid "Search Donations" +msgstr "" + +#. module: donation +#: field:donation.line,sequence:0 +msgid "Sequence" +msgstr "" + +#. module: donation +#: help:product.template,donation:0 +msgid "Specify if the product can be selectedin a donation line." +msgstr "" + +#. module: donation +#: field:donation.campaign,start_date:0 +msgid "Start Date" +msgstr "" + +#. module: donation +#: field:donation.donation,state:0 +msgid "State" +msgstr "" + +#. module: donation +#: field:donation.line,unit_price:0 +msgid "Unit Price" +msgstr "" + +#. module: donation +#: model:res.groups,name:donation.group_donation_user +msgid "User" +msgstr "" + +#. module: donation +#: model:ir.model,name:donation.model_res_users +msgid "Users" +msgstr "" + +#. module: donation +#: view:donation.donation:0 +msgid "Validate" msgstr "" diff --git a/donation/i18n/fr.po b/donation/i18n/fr.po index 356e64b53..cf23fc357 100644 --- a/donation/i18n/fr.po +++ b/donation/i18n/fr.po @@ -1,211 +1,345 @@ # Translation of OpenERP Server. # This file contains the translation of the following modules: -# * donation +# * donation # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: OpenERP Server 8.0alpha1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-03-13 08:55+0000\n" -"PO-Revision-Date: 2014-03-13 08:55+0000\n" +"POT-Creation-Date: 2014-07-01 13:43+0000\n" +"PO-Revision-Date: 2014-07-01 15:54+0100\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: \n" +"X-Generator: Poedit 1.5.7\n" #. module: donation -#: code:addons/donation/donation.py:227 -#, python-format -msgid "Missing price on product" -msgstr "Prix manquant sur le produit" +#: field:res.partner,donation_count:0 +msgid "# of Donations" +msgstr "# de dons" #. module: donation -#: field:donation.donation,state:0 -msgid "State" -msgstr "État" +#: field:res.partner,stay_count:0 +msgid "# of Stays" +msgstr "# de séjours" #. module: donation -#: selection:donation.donation,state:0 -msgid "Draft" -msgstr "Brouillon" +#: field:donation.donation,move_id:0 +msgid "Account Move" +msgstr "Ecriture comptable" #. module: donation -#: view:donation.line:0 -msgid "Donation Line" -msgstr "Ligne de don" +#: field:donation.line,amount:0 +msgid "Amount" +msgstr "Montant" #. module: donation -#: field:donation.line,product_id:0 -msgid "Product" -msgstr "Produit" +#: field:donation.report,amount_company_currency:0 +msgid "Amount Company Currency" +msgstr "Montant dans la devise de la Sté" #. module: donation -#: code:addons/donation/donation.py:135 -#, python-format -msgid "The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment." -msgstr "The donation is in currency '%s' but the company '%s' has a currency '%s'. We don't handle that for the moment." +#: field:donation.donation,amount_total:0 +msgid "Amount Total" +msgstr "Montant total" #. module: donation -#: field:donation.donation,company_id:0 -msgid "Company" -msgstr "Société" +#: field:donation.donation,amount_total_company_currency:0 +msgid "Amount Total in Company Currency" +msgstr "Montant total dans la devise de la Sté" + +#. module: donation +#: field:donation.line,amount_company_currency:0 +msgid "Amount in Company Currency" +msgstr "Montant dans la devise de la Sté" + +#. module: donation +#: field:donation.line,analytic_account_id:0 +msgid "Analytic Account" +msgstr "Compte analytique" #. module: donation #: view:donation.donation:0 -#: field:donation.line,donation_id:0 -#: model:res.groups,name:donation.group_donation -msgid "Donation" -msgstr "Don" +msgid "Back to Draft" +msgstr "Retour à l'état brouillon" #. module: donation -#: constraint:donation.donation:0 -msgid "Date must be today or in the past" -msgstr "Date must be today or in the past" +#: view:donation.donation:0 +msgid "Campaign" +msgstr "Campagne de don" + +#. module: donation +#: field:donation.report,product_categ_id:0 +msgid "Category of Product" +msgstr "Catégorie de produit" + +#. module: donation +#: field:donation.donation,check_total:0 +msgid "Check Amount" +msgstr "Montant" + +#. module: donation +#: field:donation.campaign,code:0 +msgid "Code" +msgstr "Code" + +#. module: donation +#: model:ir.model,name:donation.model_donation_campaign +msgid "Code attributed for a Donation Campaign" +msgstr "Code attribué pour une campagne de don" + +#. module: donation +#: field:donation.donation,company_id:0 view:donation.report:0 +#: field:donation.report,company_id:0 +msgid "Company" +msgstr "Société" #. module: donation #: field:donation.donation,company_currency_id:0 msgid "Company Currency" -msgstr "Company Currency" +msgstr "Monnaie de la Société" #. module: donation -#: field:donation.donation,line_ids:0 -#: model:ir.model,name:donation.model_donation_line -msgid "Donation Lines" -msgstr "Donation Lines" +#: model:ir.ui.menu,name:donation.donation_config_menu +msgid "Configuration" +msgstr "Configuration" #. module: donation -#: field:donation.donation,donation_date:0 -msgid "Donation Date" -msgstr "Date du don" +#: field:donation.donation,create_uid:0 +msgid "Created by" +msgstr "Créé par" #. module: donation -#: view:donation.donation:0 -msgid "Validate" -msgstr "Validate" +#: field:donation.donation,currency_id:0 +msgid "Currency" +msgstr "Devise" #. module: donation -#: code:addons/donation/donation.py:228 -#, python-format -msgid "The sale price on product '%s' is 0!" -msgstr "The sale price on product '%s' is 0!" +#: field:res.users,context_donation_campaign_id:0 +msgid "Current Donation Campaign" +msgstr "Campagne de don courante" #. module: donation -#: field:donation.donation,partner_categ_id:0 -msgid "Categories" -msgstr "Categories" +#: view:donation.donation:0 view:donation.report:0 +msgid "Date" +msgstr "Date" #. module: donation -#: sql_constraint:donation.donation:0 -msgid "A donation with this number already exists for this company" -msgstr "A donation with this number already exists for this company" +#: constraint:donation.donation:0 +msgid "Date must be today or in the past" +msgstr "La date doit être du jour ou passée" #. module: donation -#: field:donation.donation,number:0 -msgid "Donation Number" -msgstr "Donation Number" +#: view:donation.donation:0 field:donation.line,donation_id:0 +#: model:ir.module.category,name:donation.module_category_donation +#: view:product.product:0 +msgid "Donation" +msgstr "Don" #. module: donation -#: code:addons/donation/donation.py:134 -#: code:addons/donation/donation.py:153 -#, python-format -msgid "Error:" -msgstr "Error:" +#: view:donation.campaign:0 field:donation.donation,campaign_id:0 +#: view:donation.report:0 field:donation.report,campaign_id:0 +msgid "Donation Campaign" +msgstr "Campagne de don" #. module: donation -#: model:ir.model,name:donation.model_res_company -msgid "Companies" -msgstr "Sociétés" +#: view:donation.campaign:0 +#: model:ir.actions.act_window,name:donation.donation_campaign_action +#: model:ir.ui.menu,name:donation.donation_campaign_menu +msgid "Donation Campaigns" +msgstr "Campagnes de don" #. module: donation -#: field:donation.donation,company_email:0 -msgid "Company Email" -msgstr "Company Email" +#: field:donation.donation,donation_date:0 +#: field:donation.report,donation_date:0 +msgid "Donation Date" +msgstr "Date du don" #. module: donation -#: field:donation.line,amount:0 -msgid "Amount" -msgstr "Amount" +#: view:donation.line:0 +msgid "Donation Line" +msgstr "Ligne de don" + +#. module: donation +#: field:donation.donation,line_ids:0 +#: model:ir.model,name:donation.model_donation_line +msgid "Donation Lines" +msgstr "Lignes de don" #. module: donation +#: field:donation.donation,number:0 +msgid "Donation Number" +msgstr "Numéro de don" + +#. module: donation +#: view:donation.donation:0 #: model:ir.actions.act_window,name:donation.donation_action +#: model:ir.actions.act_window,name:donation.partner_donation_action #: model:ir.model,name:donation.model_donation_donation #: model:ir.ui.menu,name:donation.donation_menu +#: model:ir.ui.menu,name:donation.donation_report_title_menu #: model:ir.ui.menu,name:donation.donation_title_menu -#: view:res.company:0 +#: model:ir.ui.menu,name:donation.donation_top_menu view:res.partner:0 +#: field:res.partner,donation_ids:0 msgid "Donations" -msgstr "Donations" +msgstr "Dons" #. module: donation -#: selection:donation.donation,state:0 -msgid "Waiting Currency Conversion" -msgstr "Waiting Currency Conversion" +#: view:donation.report:0 +#: model:ir.actions.act_window,name:donation.donation_report_action +#: model:ir.model,name:donation.model_donation_report +#: model:ir.ui.menu,name:donation.donation_report_menu +msgid "Donations Analysis" +msgstr "Analyse des dons" #. module: donation -#: field:donation.donation,move_id:0 -msgid "Account Move" -msgstr "Account Move" +#: model:ir.actions.act_window,name:donation.donation_line_action +msgid "Donations Lines" +msgstr "Lignes de dons" #. module: donation -#: field:donation.donation,check_total:0 -msgid "Check Amount" -msgstr "Check Amount" +#: view:donation.donation:0 selection:donation.donation,state:0 +msgid "Done" +msgstr "Validé" #. module: donation -#: field:res.company,donation_bank_account_id:0 -msgid "Bank Account for Donations" -msgstr "Bank Account for Donations" +#: field:donation.donation,partner_id:0 field:donation.report,partner_id:0 +msgid "Donor" +msgstr "Donateur" #. module: donation -#: code:addons/donation/donation.py:154 -#, python-format -msgid "Missing income account on product '%s' or on it's related product category" -msgstr "Missing income account on product '%s' or on it's related product category" +#: model:ir.ui.menu,name:donation.donor +msgid "Donors" +msgstr "Donateurs" #. module: donation -#: field:donation.line,sequence:0 -msgid "Sequence" -msgstr "Sequence" +#: model:product.category,name:donation.product_category_donation +msgid "Dons" +msgstr "Dons" #. module: donation -#: sql_constraint:donation.line:0 -msgid "The amount must be positive or 0." -msgstr "The amount must be positive or 0." +#: view:donation.donation:0 selection:donation.donation,state:0 +msgid "Draft" +msgstr "Brouillon" #. module: donation -#: field:donation.donation,partner_id:0 -msgid "Donor" -msgstr "Donor" +#: view:donation.donation:0 view:donation.report:0 +msgid "Group By" +msgstr "Grouper par" #. module: donation -#: field:donation.donation,currency_id:0 -msgid "Currency" -msgstr "Currency" +#: field:product.template,donation:0 +msgid "Is a Donation" +msgstr "Don" #. module: donation -#: selection:donation.donation,state:0 -msgid "Done" -msgstr "Done" +#: model:ir.model,name:donation.model_account_journal +msgid "Journal" +msgstr "Journal" #. module: donation -#: model:ir.model,name:donation.model_account_invoice -msgid "Invoice" -msgstr "Facture" +#: model:ir.module.category,description:donation.module_category_donation +msgid "Manage donations" +msgstr "Gérer les dons" #. module: donation -#: model:ir.actions.act_window,name:donation.donation_line_action -#: model:ir.ui.menu,name:donation.donation_line_menu -msgid "Donations Lines" -msgstr "Donations Lines" +#: model:res.groups,name:donation.group_donation_manager +msgid "Manager" +msgstr "Responsable" + +#. module: donation +#: field:donation.campaign,name:0 +msgid "Name" +msgstr "Nom" + +#. module: donation +#: field:donation.campaign,nota:0 +msgid "Notes" +msgstr "Notes" + +#. module: donation +#: view:donation.donation:0 view:donation.report:0 +#: model:ir.model,name:donation.model_res_partner +msgid "Partner" +msgstr "Partenaire" #. module: donation #: field:donation.donation,journal_id:0 -msgid "Journal" -msgstr "Journal" +msgid "Payment Method" +msgstr "Méthode de paiement" #. module: donation -#: field:donation.donation,amount_total:0 -msgid "Amount Total" -msgstr "Amount Total" +#: field:donation.line,product_id:0 view:donation.report:0 +#: field:donation.report,product_id:0 +#: model:ir.model,name:donation.model_product_product +msgid "Product" +msgstr "Produit" + +#. module: donation +#: view:donation.report:0 +msgid "Product Category" +msgstr "Catégorie de produit" + +#. module: donation +#: model:ir.model,name:donation.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_product_action +#: model:ir.ui.menu,name:donation.donation_products +msgid "Products" +msgstr "Articles" + +#. module: donation +#: field:donation.line,quantity:0 +msgid "Quantity" +msgstr "Quantité" +#. module: donation +#: view:donation.donation:0 +msgid "Search Donations" +msgstr "Recherche des dons" + +#. module: donation +#: field:donation.line,sequence:0 +msgid "Sequence" +msgstr "Séquence" + +#. module: donation +#: help:product.template,donation:0 +msgid "Specify if the product can be selected in a donation line." +msgstr "Spécifier si le produit peut être sélectionné dans une ligne de don." + +#. module: donation +#: field:donation.campaign,start_date:0 +msgid "Start Date" +msgstr "Date de départ" + +#. module: donation +#: field:donation.donation,state:0 +msgid "State" +msgstr "État" + +#. module: donation +#: field:donation.line,unit_price:0 +msgid "Unit Price" +msgstr "Prix unitaire" + +#. module: donation +#: model:res.groups,name:donation.group_donation_user +msgid "User" +msgstr "Utilisateur" + +#. module: donation +#: model:ir.model,name:donation.model_res_users +msgid "Users" +msgstr "Utilisateurs" + +#. module: donation +#: view:donation.donation:0 +msgid "Validate" +msgstr "Valider" diff --git a/donation/product.py b/donation/product.py index 80185b2e1..fbece0f29 100644 --- a/donation/product.py +++ b/donation/product.py @@ -28,7 +28,7 @@ class product_template(orm.Model): _columns = { 'donation': fields.boolean( 'Is a Donation', - help="Specify if the product can be selected" + help="Specify if the product can be selected " "in a donation line."), } From f6280f10de9119cdbe694ce5b4f0a1d011c1ca49 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 3 Jul 2014 15:38:47 +0200 Subject: [PATCH 025/172] Update layout of options in product view. Adapt to v8 for product.template/product.product in XML. --- donation/product_demo.xml | 9 +++------ donation/product_view.xml | 6 ++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/donation/product_demo.xml b/donation/product_demo.xml index 8761a1ed0..bede4b4f7 100644 --- a/donation/product_demo.xml +++ b/donation/product_demo.xml @@ -3,10 +3,11 @@ - + Donation + DON - 0 + 1 0 service @@ -14,10 +15,6 @@ This is a donation product. - - - DON - diff --git a/donation/product_view.xml b/donation/product_view.xml index c6f47dc73..96f6b5b24 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -20,8 +20,10 @@
- -
From b3189bcbb4a0f663df6344cfc162ede2ef0303f4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 3 Jul 2014 18:27:03 +0200 Subject: [PATCH 026/172] When a field is added on product.template, we must only inherit the template view. --- donation/product_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/donation/product_view.xml b/donation/product_view.xml index 96f6b5b24..164391930 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -14,10 +14,10 @@
- + donation.product.product.form - product.product - + product.template +
From b324c1e86f483d5fcf256e1172f9cd32b574590f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 3 Jul 2014 19:41:07 +0200 Subject: [PATCH 027/172] Product menu entries now point to product.template, to be coherent with the rest of Odoo v8 rename variable filter_to_donation filter_donation Add filter for Tax receipt Inherit search view of product.template instead of product.product --- donation/donation_view.xml | 9 --------- donation/product_view.xml | 22 ++++++++++++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 795fb5d86..c21f5870d 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -151,14 +151,5 @@ - - Products - product.product - kanban,tree,form - {'search_default_filter_to_donation': 1} - - - - diff --git a/donation/product_view.xml b/donation/product_view.xml index 164391930..5107f2c86 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -3,19 +3,19 @@ - - donation.product.product.search - product.product - + + donation.product.template.search + product.template + - + - donation.product.product.form + donation.product.template.form product.template @@ -28,5 +28,15 @@ + + Products + product.template + kanban,tree,form + {'search_default_filter_donation': 1} + + + + + From facaad9fdc90cf9eb8325930db70df6b4b9bd3c6 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 4 Jul 2014 17:20:56 +0200 Subject: [PATCH 028/172] Hide Donation menu for users that are not part of the Donation group Update strings and translation. --- donation/donation_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index c21f5870d..858eabdfe 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -141,7 +141,7 @@ tree,form - + From b2e383831d18392200419b3023ddd3502443fb6d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 4 Sep 2014 22:09:09 +0200 Subject: [PATCH 029/172] Convert webkit stay journal to qweb Add company_id field i stay views Add Contact menu entry in Stay menu PEP8 stuff --- donation/donation.py | 40 ++++++++++++++++++++++++----------- donation/donation_campaign.py | 3 ++- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 97df83bb9..bed937e84 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -92,13 +92,19 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): 'amount_total': fields.function( _compute_total, type='float', multi="donation", string='Amount Total', store={ - 'donation.line': (_get_donation_from_lines, ['unit_price', 'quantity', 'donation_id'], 10), + 'donation.line': ( + _get_donation_from_lines, + ['unit_price', 'quantity', 'donation_id'], 10), }), 'amount_total_company_currency': fields.function( _compute_total, type='float', multi="donation", string='Amount Total in Company Currency', store={ - 'donation.donation': (lambda self, cr, uid, ids, c={}: ids, ['currency_id', 'journal_id'], 10), - 'donation.line': (_get_donation_from_lines, ['unit_price', 'quantity', 'donation_id'], 20), + 'donation.donation': ( + lambda self, cr, uid, ids, c={}: ids, + ['currency_id', 'journal_id'], 10), + 'donation.line': ( + _get_donation_from_lines, + ['unit_price', 'quantity', 'donation_id'], 20), }), 'donation_date': fields.date( 'Donation Date', required=True, @@ -198,11 +204,14 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): amount_total_company_cur += donation_line.amount_company_currency account_id = donation_line.product_id.property_account_income.id if not account_id: - account_id = donation_line.product_id.categ_id.property_account_income_categ.id + account_id = donation_line.product_id.categ_id.\ + property_account_income_categ.id if not account_id: raise orm.except_orm( _('Error:'), - _("Missing income account on product '%s' or on it's related product category") % donation_line.product_id.name) + _("Missing income account on product '%s' or on it's " + "related product category") + % donation_line.product_id.name) analytic_account_id = self._get_analytic_account_id( cr, uid, donation_line, account_id, context=context) if not currency_id: @@ -218,11 +227,12 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): if currency_id: amount_currency = donation_line.amount - #TODO Take into account the option group_invoice_lines ?? + # TODO Take into account the option group_invoice_lines ? if (account_id, analytic_account_id) in aml: aml[(account_id, analytic_account_id)]['credit'] += credit aml[(account_id, analytic_account_id)]['debit'] += debit - aml[(account_id, analytic_account_id)]['amount_currency'] += amount_currency + aml[(account_id, analytic_account_id)]['amount_currency'] \ + += amount_currency else: aml[(account_id, analytic_account_id)] = { 'credit': credit, @@ -285,7 +295,8 @@ def validate(self, cr, uid, ids, context=None): if donation.check_total != donation.amount_total: raise orm.except_orm( _('Error:'), - _("The amount of the donation (%s) is different from the sum of the donation lines (%s).") + _("The amount of the donation (%s) is different from " + "the sum of the donation lines (%s).") % (donation.check_total, donation.amount_total)) donation_write_vals = {'state': 'done'} @@ -367,14 +378,20 @@ def _get_lines_from_donation(self, cr, uid, ids, context=None): 'amount': fields.function( _compute_amount, multi="donline", type="float", string='Amount', digits_compute=dp.get_precision('Account'), store={ - 'donation.line': (lambda self, cr, uid, ids, c={}: ids, ['quantity', 'unit_price'], 10), + 'donation.line': ( + lambda self, cr, uid, ids, c={}: ids, + ['quantity', 'unit_price'], 10), }), 'amount_company_currency': fields.function( _compute_amount, multi="donline", type="float", string='Amount in Company Currency', digits_compute=dp.get_precision('Account'), store={ - 'donation.line': (lambda self, cr, uid, ids, c={}: ids, ['quantity', 'unit_price'], 10), - 'donation.donation': (_get_lines_from_donation, ['journal_id', 'currency_id'], 10), + 'donation.line': ( + lambda self, cr, uid, ids, c={}: ids, + ['quantity', 'unit_price'], 10), + 'donation.donation': ( + _get_lines_from_donation, + ['journal_id', 'currency_id'], 10), }), 'analytic_account_id': fields.many2one( 'account.analytic.account', 'Analytic Account', @@ -398,7 +415,6 @@ def product_id_change(self, cr, uid, ids, product_id, context): class res_partner(orm.Model): _inherit = 'res.partner' - def _donation_count(self, cr, uid, ids, field_name, arg, context=None): res = dict(map(lambda x: (x, 0), ids)) # The current user may not have access rights for donations diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py index 4a850c9e0..0705f33e2 100644 --- a/donation/donation_campaign.py +++ b/donation/donation_campaign.py @@ -33,7 +33,8 @@ def name_get(self, cr, uid, ids, context=None): ids = [ids] for record in self.browse(cr, uid, ids, context=context): if record.code: - res.append((record.id, u'[%s] %s' % (record.code, record.name))) + res.append( + (record.id, u'[%s] %s' % (record.code, record.name))) else: res.append((record.id, record.name)) return res From 13073ad7a0f0d0b429ccb76f13b25bd042516334 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 8 Oct 2014 09:41:54 +0200 Subject: [PATCH 030/172] Fix v8 regression. --- donation/donation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/donation/donation.py b/donation/donation.py index bed937e84..22371dcac 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -333,7 +333,7 @@ def back_to_draft(self, cr, uid, ids, context=None): cr, uid, [donation.move_id.id], context=context) self.pool['account.move'].unlink( cr, uid, donation.move_id.id, context=context) - donation.write({'state': 'draft'}, context=context) + donation.write({'state': 'draft'}) return True From f41f63ffa74e911fcecc9f4106297a9ec4c6014d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 8 Oct 2014 12:20:51 +0200 Subject: [PATCH 031/172] Update the management of payment methods and currencies Use copy= in field definition Update donation search view Ability to save the Default Payment method --- donation/__openerp__.py | 3 +- donation/account_view.xml | 19 +++ donation/donation.py | 139 ++++++++---------- donation/donation_demo.xml | 15 +- donation/donation_view.xml | 6 +- ...{campaign_user_view.xml => users_view.xml} | 3 + 6 files changed, 95 insertions(+), 90 deletions(-) create mode 100644 donation/account_view.xml rename donation/{campaign_user_view.xml => users_view.xml} (85%) diff --git a/donation/__openerp__.py b/donation/__openerp__.py index 0262a5516..4cffa7aa9 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -40,9 +40,10 @@ 'data': [ 'security/donation_security.xml', 'donation_view.xml', + 'account_view.xml', 'product_view.xml', 'donation_campaign_view.xml', - 'campaign_user_view.xml', + 'users_view.xml', 'security/ir.model.access.csv', 'partner_view.xml', 'report/donation_report_view.xml', diff --git a/donation/account_view.xml b/donation/account_view.xml new file mode 100644 index 000000000..25fa0600a --- /dev/null +++ b/donation/account_view.xml @@ -0,0 +1,19 @@ + + + + + + + donation.account.journal.form + account.journal + + + + + + + + + + diff --git a/donation/donation.py b/donation/donation.py index 22371dcac..f5e134e8b 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -32,6 +32,11 @@ class res_users(orm.Model): _columns = { 'context_donation_campaign_id': fields.many2one( 'donation.campaign', 'Current Donation Campaign'), + 'context_donation_journal_id': fields.many2one( + 'account.journal', 'Current Donation Payment Method', + domain=[ + ('type', 'in', ('bank', 'cash')), + ('allow_donation', '=', True)]), # begin with context_ to allow user to change it by itself } @@ -70,19 +75,10 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): cr, uid, [('line_ids', 'in', ids)], context=context) return res - def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): - res = {} - for donation in self.browse(cr, uid, ids, context=context): - if donation.journal_id.currency: - res[donation.id] = donation.journal_id.currency.id - else: - res[donation.id] = donation.company_id.currency_id.id - return res - _columns = { - 'currency_id': fields.function( - _get_donation_currency, type='many2one', relation='res.currency', - string='Currency'), + 'currency_id': fields.many2one( + 'res.currency', 'Currency', required=True, + states={'done': [('readonly', True)]}), 'partner_id': fields.many2one( 'res.partner', 'Donor', required=True, states={'done': [('readonly', True)]}), @@ -116,18 +112,20 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): 'donation.line', 'donation_id', 'Donation Lines', states={'done': [('readonly', True)]}), 'move_id': fields.many2one( - 'account.move', 'Account Move', readonly=True), + 'account.move', 'Account Move', readonly=True, copy=False), 'number': fields.related( 'move_id', 'name', type='char', readonly=True, size=64, relation='account.move', store=True, string='Donation Number'), 'journal_id': fields.many2one( 'account.journal', 'Payment Method', required=True, - domain=[('type', '=', 'donation')], + domain=[ + ('type', 'in', ('bank', 'cash')), + ('allow_donation', '=', True)], states={'done': [('readonly', True)]}), 'state': fields.selection([ ('draft', 'Draft'), ('done', 'Done'), - ], 'State', readonly=True), + ], 'State', readonly=True, copy='draft'), 'company_currency_id': fields.related( 'company_id', 'currency_id', type='many2one', relation="res.currency", string="Company Currency"), @@ -137,18 +135,18 @@ def _get_donation_currency(self, cr, uid, ids, name, arg, context=None): } def default_get(self, cr, uid, fields_list, context=None): - res = {'state': 'draft'} user = self.pool['res.users'].browse(cr, uid, uid, context=context) - res['company_id'] = self.pool['res.company']._company_default_get( + company_id = self.pool['res.company']._company_default_get( cr, uid, 'donation.donation', context=context) - journal_ids = self.pool['account.journal'].search( - cr, uid, [ - ('company_id', '=', res['company_id']), - ('type', '=', 'donation'), - ], context=context) - if journal_ids: # Take first donation journal - res['journal_id'] = journal_ids[0] - res['campaign_id'] = user.context_donation_campaign_id.id or False + company = self.pool['res.company'].browse( + cr, uid, company_id, context=context) + res = { + 'state': 'draft', + 'journal_id': user.context_donation_journal_id.id or False, + 'campaign_id': user.context_donation_campaign_id.id or False, + 'company_id': company_id, + 'currency_id': company.currency_id.id, + } return res def _check_donation_date(self, cr, uid, ids): @@ -191,10 +189,10 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): currency_id = donation.currency_id.id else: currency_id = False - total_amount_currency = 0.0 # Note : we can have negative donations for donors that use direct # debit when their direct debit rejected by the bank amount_total_company_cur = 0.0 + total_amount_currency = 0.0 name = _('Don de %s') % donation.partner_id.name aml = {} @@ -214,18 +212,15 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): % donation_line.product_id.name) analytic_account_id = self._get_analytic_account_id( cr, uid, donation_line, account_id, context=context) - if not currency_id: - amount_currency = 0.0 + amount_currency = 0.0 if donation_line.amount_company_currency > 0: credit = donation_line.amount_company_currency debit = 0 - if currency_id: - amount_currency = donation_line.amount * -1 + amount_currency = donation_line.amount * -1 else: debit = donation_line.amount_company_currency * -1 credit = 0 - if currency_id: - amount_currency = donation_line.amount + amount_currency = donation_line.amount # TODO Take into account the option group_invoice_lines ? if (account_id, analytic_account_id) in aml: @@ -249,20 +244,19 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): 'analytic_account_id': analytic_account_id, 'partner_id': donation.partner_id.id, 'currency_id': currency_id, - 'amount_currency': content['amount_currency'], + 'amount_currency': ( + currency_id and content['amount_currency'] or 0.0), })) # counter-part if amount_total_company_cur > 0: debit = amount_total_company_cur credit = 0 - if currency_id: - total_amount_currency = donation.amount_total + total_amount_currency = donation.amount_total else: credit = amount_total_company_cur * -1 debit = 0 - if currency_id: - total_amount_currency = donation.amount_total * -1 + total_amount_currency = donation.amount_total * -1 movelines.append( (0, 0, { 'debit': debit, @@ -271,7 +265,8 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): 'account_id': donation.journal_id.default_debit_account_id.id, 'partner_id': donation.partner_id.id, 'currency_id': currency_id, - 'amount_currency': total_amount_currency, + 'amount_currency': ( + currency_id and total_amount_currency or 0.0), })) vals = { @@ -313,15 +308,6 @@ def validate(self, cr, uid, ids, context=None): self.write(cr, uid, donation.id, donation_write_vals, context=context) return True - def copy(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - default['state'] = 'draft' - default['move_id'] = False - res = super(donation_donation, self).copy( - cr, uid, id, default=default, context=context) - return res - def partner_id_change(self, cr, uid, ids, partner_id, context=None): return {} @@ -336,6 +322,17 @@ def back_to_draft(self, cr, uid, ids, context=None): donation.write({'state': 'draft'}) return True + def unlink(self, cr, uid, ids, context=None): + for donation in self.browse(cr, uid, ids, context=context): + if donation.state == 'done': + raise orm.except_orm( + _('Error:'), + _("The donation '%s' is in Done state, so you must " + "set it back to draft before deleting it.") + % donation.number) + return super(donation_donation, self).unlink( + cr, uid, ids, context=context) + class donation_line(orm.Model): _name = 'donation.line' @@ -427,43 +424,31 @@ def _donation_count(self, cr, uid, ids, field_name, arg, context=None): _columns = { 'donation_ids': fields.one2many( - 'donation.donation', 'partner_id', 'Donations'), + 'donation.donation', 'partner_id', 'Donations', copy=False), 'donation_count': fields.function( _donation_count, string="# of Donations", type='integer'), } - def copy(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - default.update({ - 'donation_ids': False, - }) - return super(res_partner, self).copy( - cr, uid, id, default=default, context=context) - class account_journal(orm.Model): _inherit = 'account.journal' _columns = { - 'type': fields.selection([ - ('sale', 'Sale'), - ('sale_refund', 'Sale Refund'), - ('purchase', 'Purchase'), - ('purchase_refund', 'Purchase Refund'), - ('cash', 'Cash'), - ('bank', 'Bank and Checks'), - ('general', 'General'), - ('situation', 'Opening/Closing Situation'), - ('donation', 'Donation'), - ], 'Type', size=32, required=True, - help="Select 'Sale' for customer invoices journals. " - "Select 'Purchase' for supplier invoices journals. " - "Select 'Cash' or 'Bank' for journals that are used in " - "customer or supplier payments. " - "Select 'General' for miscellaneous operations journals. " - "Select 'Opening/Closing Situation' for entries generated for " - " new fiscal years. " - "Select 'Donations' for donation journals." - ), + 'allow_donation': fields.boolean('Donation Payment Method'), } + + def _check_donation(self, cr, uid, ids): + for journal in self.browse(cr, uid, ids): + if journal.allow_donation and journal.type not in ('bank', 'cash'): + raise orm.except_orm( + _('Error:'), + _("The journal '%s' has the option 'Allow Donation', " + "so it's type should be 'Cash' or 'Bank and Checks.") + % journal.name) + return True + + _constraints = [( + _check_donation, + 'Wrong configuration of journal', + ['type', 'allow_donation'] + )] diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 368cd167f..ca050f0fb 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -3,19 +3,12 @@ - - Account Donation Journal - DON/ - 6 - + + - - Donation Journal - DON - donation - - + + diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 858eabdfe..9e2b8f9e9 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -24,9 +24,10 @@ on_change="partner_id_change(partner_id, context)" domain="[('customer', '=', True)]"/> + - @@ -56,6 +57,7 @@ + @@ -77,6 +79,8 @@ + + diff --git a/donation/campaign_user_view.xml b/donation/users_view.xml similarity index 85% rename from donation/campaign_user_view.xml rename to donation/users_view.xml index a38006232..353fd471f 100644 --- a/donation/campaign_user_view.xml +++ b/donation/users_view.xml @@ -9,6 +9,7 @@ + @@ -20,6 +21,8 @@ + From 8440d4f3b7d1151ad9273e566634823a6f38c544 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 8 Oct 2014 15:23:24 +0200 Subject: [PATCH 032/172] Add payment_ref on donation Update donation from stay wizard following the changes in my previous commit on the big update of payment methods Remove version="7.0" --- donation/donation.py | 19 +++++++++++++++++-- donation/donation_campaign_view.xml | 2 +- donation/donation_view.xml | 7 +++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index f5e134e8b..aa2d611bb 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -122,6 +122,9 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): ('type', 'in', ('bank', 'cash')), ('allow_donation', '=', True)], states={'done': [('readonly', True)]}), + 'payment_ref': fields.char( + 'Payment Reference', size=32, + states={'done': [('readonly', True)]}), 'state': fields.selection([ ('draft', 'Draft'), ('done', 'Done'), @@ -193,7 +196,7 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): # debit when their direct debit rejected by the bank amount_total_company_cur = 0.0 total_amount_currency = 0.0 - name = _('Don de %s') % donation.partner_id.name + name = _('Donation of %s') % donation.partner_id.name aml = {} # key = (account_id, analytic_account_id) @@ -273,7 +276,7 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): 'journal_id': donation.journal_id.id, 'date': donation.donation_date, 'period_id': period_id, - 'ref': False, # TODO + 'ref': donation.payment_ref, 'line_id': movelines, } return vals @@ -311,6 +314,18 @@ def validate(self, cr, uid, ids, context=None): def partner_id_change(self, cr, uid, ids, partner_id, context=None): return {} + def save_default_values(self, cr, uid, ids, context=None): + assert len(ids) == 1, 'Only 1 ID' + donation = self.browse(cr, uid, ids[0], context=context) + self.pool['res.users'].write( + cr, uid, uid, { + 'context_donation_journal_id': + donation.journal_id.id or False, + 'context_donation_campaign_id': + donation.campaign_id.id or False, + }, context=context) + return + def back_to_draft(self, cr, uid, ids, context=None): assert len(ids) == 1, 'only one ID for back2draft' donation = self.browse(cr, uid, ids[0], context=context) diff --git a/donation/donation_campaign_view.xml b/donation/donation_campaign_view.xml index aad9f3d2e..cec492a82 100644 --- a/donation/donation_campaign_view.xml +++ b/donation/donation_campaign_view.xml @@ -13,7 +13,7 @@ donation.campaign.form donation.campaign -
+ diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 9e2b8f9e9..40d61a25c 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -7,7 +7,7 @@ donation.form donation.donation - +
@@ -28,6 +30,7 @@ groups="base.group_multi_currency"/> +
@@ -118,7 +121,7 @@ donation.line.form donation.line - + From 307fe334c07a198933e4ffbdf21cb58c92480be3 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 9 Oct 2014 14:16:04 +0200 Subject: [PATCH 033/172] Add module donation_recurring to handle recurring donations Add module donation_recurring_tax_receipt Add donation validation wizard to validate several donations at the same time --- donation/__init__.py | 1 + donation/__openerp__.py | 1 + donation/donation.py | 37 ++++++++++++++------ donation/donation_view.xml | 18 ++++++---- donation/wizard/__init__.py | 22 ++++++++++++ donation/wizard/donation_validate.py | 38 +++++++++++++++++++++ donation/wizard/donation_validate_view.xml | 39 ++++++++++++++++++++++ 7 files changed, 139 insertions(+), 17 deletions(-) create mode 100644 donation/wizard/__init__.py create mode 100644 donation/wizard/donation_validate.py create mode 100644 donation/wizard/donation_validate_view.xml diff --git a/donation/__init__.py b/donation/__init__.py index 142385ad8..27727c046 100644 --- a/donation/__init__.py +++ b/donation/__init__.py @@ -23,3 +23,4 @@ from . import donation from . import product from . import report +from . import wizard diff --git a/donation/__openerp__.py b/donation/__openerp__.py index 4cffa7aa9..feb8313e2 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -47,6 +47,7 @@ 'security/ir.model.access.csv', 'partner_view.xml', 'report/donation_report_view.xml', + 'wizard/donation_validate_view.xml', ], 'demo': [ 'product_demo.xml', diff --git a/donation/donation.py b/donation/donation.py index aa2d611bb..f3d981daa 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -32,8 +32,11 @@ class res_users(orm.Model): _columns = { 'context_donation_campaign_id': fields.many2one( 'donation.campaign', 'Current Donation Campaign'), - 'context_donation_journal_id': fields.many2one( - 'account.journal', 'Current Donation Payment Method', + # TODO : a write on this field via the interface + # is not saved and I don't know why + 'context_donation_journal_id': fields.property( + type='many2one', relation='account.journal', + string='Current Donation Payment Method', domain=[ ('type', 'in', ('bank', 'cash')), ('allow_donation', '=', True)]), @@ -110,7 +113,7 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): states={'done': [('readonly', True)]}), 'line_ids': fields.one2many( 'donation.line', 'donation_id', 'Donation Lines', - states={'done': [('readonly', True)]}), + states={'done': [('readonly', True)]}, copy=True), 'move_id': fields.many2one( 'account.move', 'Account Move', readonly=True, copy=False), 'number': fields.related( @@ -153,18 +156,23 @@ def default_get(self, cr, uid, fields_list, context=None): return res def _check_donation_date(self, cr, uid, ids): + # I don't have the context, so I can't use fields.date.context_today today_dt = datetime.today() today_str = today_dt.strftime(DEFAULT_SERVER_DATE_FORMAT) for donation in self.browse(cr, uid, ids): if donation.donation_date > today_str: - return False + raise orm.except_orm( + _('Error:'), + _('The date of the donation of %s should be today ' + 'or in the past, not in the future!') + % donation.partner_id.name) return True _constraints = [( _check_donation_date, - "Date must be today or in the past", + "Error on Donation Date", ['donation_date'] - )] + )] def _get_analytic_account_id( self, cr, uid, donation_line, account_id, context=None): @@ -288,14 +296,23 @@ def validate(self, cr, uid, ids, context=None): if not donation.line_ids: raise orm.except_orm( _('Error:'), - _('Cannot validate a donation without lines!')) + _("Cannot validate the donation of %s because it doesn't " + "have any lines!") % donation.partner_id.name) + + if donation.state != 'draft': + raise orm.except_orm( + _('Error:'), + _("Cannot validate the donation of %s because it is not " + "in draft state.") % donation.partner_id.name) + if donation.check_total != donation.amount_total: raise orm.except_orm( _('Error:'), - _("The amount of the donation (%s) is different from " - "the sum of the donation lines (%s).") - % (donation.check_total, donation.amount_total)) + _("The amount of the donation of %s (%s) is different from " + "the sum of the donation lines (%s).") % ( + donation.partner_id.name, donation.check_total, + donation.amount_total)) donation_write_vals = {'state': 'done'} diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 40d61a25c..df55e8ec5 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -11,13 +11,15 @@
@@ -43,9 +45,11 @@
- - - + + + + +
@@ -56,14 +60,14 @@ donation.donation - + - +
diff --git a/donation/wizard/__init__.py b/donation/wizard/__init__.py new file mode 100644 index 000000000..50f97fea0 --- /dev/null +++ b/donation/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for Odoo +# Copyright (C) 2014 Barroux Abbey (www.barroux.org) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import donation_validate diff --git a/donation/wizard/donation_validate.py b/donation/wizard/donation_validate.py new file mode 100644 index 000000000..44fcc7beb --- /dev/null +++ b/donation/wizard/donation_validate.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Donation module for Odoo +# Copyright (C) 2014 Barroux Abbey (www.barroux.org) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm + + +class donation_validate(orm.TransientModel): + _name = 'donation.validate' + _description = 'Validate Donations' + + def run(self, cr, uid, ids, context=None): + if context is None: + context = {} + assert context.get('active_model') == 'donation.donation',\ + 'Source model must be donations' + assert context.get('active_ids'), 'No donation selected' + for donation_id in context['active_ids']: + self.pool['donation.donation'].validate( + cr, uid, [donation_id], context=context) + return True diff --git a/donation/wizard/donation_validate_view.xml b/donation/wizard/donation_validate_view.xml new file mode 100644 index 000000000..a7b513b50 --- /dev/null +++ b/donation/wizard/donation_validate_view.xml @@ -0,0 +1,39 @@ + + + + + + + + + donation_validate.form + donation.validate + +
+

+ This wizard will validate all the draft donations selected. +

+
+
+
+
+
+ + + +
+
From f5c952fca3a8c05d877166d20be6f3df9c4c9694 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 9 Oct 2014 16:51:39 +0200 Subject: [PATCH 034/172] Update product_id_change to add an argument Remove dependancy of donation_stay on donation_tax_receipt, via the use of the on_change in the wizard Update order of donations --- donation/donation.py | 7 ++++--- donation/donation_view.xml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index f3d981daa..e5933c740 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -47,7 +47,7 @@ class res_users(orm.Model): class donation_donation(orm.Model): _name = 'donation.donation' _description = 'Donations' - _order = 'number desc, id desc' + _order = 'id desc' _rec_name = 'number' def _compute_total(self, cr, uid, ids, name, arg, context=None): @@ -328,7 +328,8 @@ def validate(self, cr, uid, ids, context=None): self.write(cr, uid, donation.id, donation_write_vals, context=context) return True - def partner_id_change(self, cr, uid, ids, partner_id, context=None): + def partner_id_change( + self, cr, uid, ids, partner_id, company_id, context=None): return {} def save_default_values(self, cr, uid, ids, context=None): @@ -432,7 +433,7 @@ def _get_lines_from_donation(self, cr, uid, ids, context=None): 'quantity': 1, } - def product_id_change(self, cr, uid, ids, product_id, context): + def product_id_change(self, cr, uid, ids, product_id, context=None): res = {'value': {}} if product_id: product = self.pool['product.product'].browse( diff --git a/donation/donation_view.xml b/donation/donation_view.xml index df55e8ec5..6ac342e76 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -25,7 +25,7 @@ Date: Fri, 10 Oct 2014 17:44:32 +0200 Subject: [PATCH 035/172] Add module donation_bank_statement Re-org donation form view with a new tab Small code enhancements --- donation/donation.py | 7 ++++++- donation/donation_view.xml | 10 +++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index e5933c740..4281f6578 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -179,6 +179,10 @@ def _get_analytic_account_id( analytic_account_id = donation_line.analytic_account_id.id or False return analytic_account_id + def _prepare_move_line_name(self, cr, uid, donation, context=None): + name = _('Donation of %s') % donation.partner_id.name + return name + def _prepare_donation_move(self, cr, uid, donation, context=None): if context is None: context = {} @@ -204,7 +208,8 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): # debit when their direct debit rejected by the bank amount_total_company_cur = 0.0 total_amount_currency = 0.0 - name = _('Donation of %s') % donation.partner_id.name + name = self._prepare_move_line_name( + cr, uid, donation, context=context) aml = {} # key = (account_id, analytic_account_id) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 6ac342e76..cb05760c5 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -37,18 +37,22 @@ - - - + + + + + + + From ac830823ca7ad826dd6e9e27916f52dad8adc1f4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 20 Oct 2014 20:44:30 +0200 Subject: [PATCH 036/172] Call super() on default_get --- donation/donation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 4281f6578..8f6d19d02 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -141,18 +141,20 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): } def default_get(self, cr, uid, fields_list, context=None): + res = super(donation_donation, self).default_get( + cr, uid, fields_list, context=context) user = self.pool['res.users'].browse(cr, uid, uid, context=context) company_id = self.pool['res.company']._company_default_get( cr, uid, 'donation.donation', context=context) company = self.pool['res.company'].browse( cr, uid, company_id, context=context) - res = { + res.update({ 'state': 'draft', 'journal_id': user.context_donation_journal_id.id or False, 'campaign_id': user.context_donation_campaign_id.id or False, 'company_id': company_id, 'currency_id': company.currency_id.id, - } + }) return res def _check_donation_date(self, cr, uid, ids): From f6e2b6c800a0551b05759c9393d9697e311153c4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 20 Oct 2014 20:51:09 +0200 Subject: [PATCH 037/172] Remove a comment (it now works !) --- donation/donation.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 8f6d19d02..c42da0e30 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -32,8 +32,6 @@ class res_users(orm.Model): _columns = { 'context_donation_campaign_id': fields.many2one( 'donation.campaign', 'Current Donation Campaign'), - # TODO : a write on this field via the interface - # is not saved and I don't know why 'context_donation_journal_id': fields.property( type='many2one', relation='account.journal', string='Current Donation Payment Method', From 346b511f5d8aa0fce9e8a5f12d31dc5a77675b03 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 21 Oct 2014 08:29:33 +0200 Subject: [PATCH 038/172] Add demo data. --- donation/donation_demo.xml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index ca050f0fb..3522171d8 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -23,5 +23,40 @@ Catalog
+ + + 100 + + + + CHQ BNP 239023 + + + + + + + 1 + 100 + + + + + 120 + + + + + + + + + + + 1 + 120 + + +
From 1275df4f8e506ca14cfc690b55eb402dc52274fb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 21 Oct 2014 09:53:53 +0200 Subject: [PATCH 039/172] FIX on_change on products for v8 Temporarily disable demo data on donation_recurring --- donation/product.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/donation/product.py b/donation/product.py index fbece0f29..8e86b9b6b 100644 --- a/donation/product.py +++ b/donation/product.py @@ -32,12 +32,16 @@ class product_template(orm.Model): "in a donation line."), } + def donation_change(self, cr, uid, ids, donation, context=None): + res = {'value': {}} + if donation: + res['value'] = {'type': 'service', 'sale_ok': False} + return res + class product_product(orm.Model): _inherit = 'product.product' def donation_change(self, cr, uid, ids, donation, context=None): - res = {} - if donation: - res['value'] = {'type': 'service', 'sale_ok': False} - return res + return self.pool['product.template'].donation_change( + cr, uid, [], donation, context=context) From f1704bee298e5149d504632b910d12ebf502a185 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 21 Oct 2014 23:58:41 +0200 Subject: [PATCH 040/172] Add country_id on donations for statistics --- donation/donation.py | 7 +++++++ donation/donation_view.xml | 1 + 2 files changed, 8 insertions(+) diff --git a/donation/donation.py b/donation/donation.py index c42da0e30..960e37a11 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -83,6 +83,13 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): 'partner_id': fields.many2one( 'res.partner', 'Donor', required=True, states={'done': [('readonly', True)]}), + # country_id is here to have stats per country + # We don't want an invalidation function, because if the partner + # moves to another country, we want to keep the old country for + # past donations + 'country_id': fields.related( + 'partner_id', 'country_id', type='many2one', + relation='res.country', store=True), 'check_total': fields.float( 'Check Amount', digits_compute=dp.get_precision('Account'), states={'done': [('readonly', True)]}), diff --git a/donation/donation_view.xml b/donation/donation_view.xml index cb05760c5..b99496310 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -89,6 +89,7 @@ + From 98b22177445c5f3cc2f49985f4c0ec3eaadfb1a8 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 22 Oct 2014 08:45:56 +0200 Subject: [PATCH 041/172] Also add country_id on the donation reporting --- donation/report/donation_report.py | 4 ++++ donation/report/donation_report_view.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/donation/report/donation_report.py b/donation/report/donation_report.py index 5a30185c2..90ec4446f 100644 --- a/donation/report/donation_report.py +++ b/donation/report/donation_report.py @@ -35,6 +35,8 @@ class donation_report(orm.Model): 'product_id': fields.many2one( 'product.product', 'Product', readonly=True), 'partner_id': fields.many2one('res.partner', 'Donor', readonly=True), + 'country_id': fields.many2one( + 'res.country', 'Partner Country', readonly=True), 'company_id': fields.many2one('res.company', 'Company', readonly=True), 'product_categ_id': fields.many2one( 'product.category', 'Category of Product', readonly=True), @@ -52,6 +54,7 @@ def _select(self): pt.categ_id AS product_categ_id, d.company_id AS company_id, d.partner_id AS partner_id, + d.country_id AS country_id, d.campaign_id AS campaign_id, sum(l.amount_company_currency) AS amount_company_currency """ @@ -78,6 +81,7 @@ def _group_by(self): pt.categ_id, d.donation_date, d.partner_id, + d.country_id, d.campaign_id, d.company_id """ diff --git a/donation/report/donation_report_view.xml b/donation/report/donation_report_view.xml index 74cad4dce..de16807b6 100644 --- a/donation/report/donation_report_view.xml +++ b/donation/report/donation_report_view.xml @@ -11,6 +11,7 @@ + From d92485b0f9f6794c5c46d0ebe1ecde502278ba4e Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 21 Nov 2014 10:52:24 +0100 Subject: [PATCH 042/172] Add access right on analytic line to donation user --- donation/security/ir.model.access.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/donation/security/ir.model.access.csv b/donation/security/ir.model.access.csv index a7339e9ff..aa2e06b7b 100644 --- a/donation/security/ir.model.access.csv +++ b/donation/security/ir.model.access.csv @@ -10,4 +10,5 @@ access_account_journal_donation,Read access on account.journal,account.model_acc access_account_journal_period_donation,Full access on account.journal.period,account.model_account_journal_period,group_donation_user,1,1,1,1 access_account_move_donation,Full access on account.move,account.model_account_move,group_donation_user,1,1,1,1 access_account_move_line_donation,Full access on account.move.line,account.model_account_move_line,group_donation_user,1,1,1,1 +access_account_analytic_line_donation,Full access on account.analytic.line to donation user,analytic.model_account_analytic_line,group_donation_user,1,1,1,1 access_donation_report,Full access on donation.report to Donation User,model_donation_report,group_donation_user,1,1,1,1 From ee365938d65f61ba762db70ac64ad70ee134d923 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 22 Nov 2014 23:47:35 +0100 Subject: [PATCH 043/172] Add/update demo data color=red for suspended recurring donation in tree view --- donation/donation_demo.xml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 3522171d8..a08fdc9bb 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -23,10 +23,30 @@ Catalog + + Rémi Duplat + + 12 rue de l'espérance + 69100 + Villeurbanne + + vincent.duplat@yahoo.example.com + + + + Lucie Dubois + + 34 rue Pierre Dupont + 69004 + Lyon + + lucie.dubois@yahoo.example.com + + 100 - + CHQ BNP 239023 @@ -43,14 +63,14 @@ 120 - + - + 1 From eb42165b04bf662c042581350386a5d58ecfc510 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 30 Nov 2014 14:20:10 +0100 Subject: [PATCH 044/172] Add tracking and chatter on donation Remove create_uid on donation.donation Donation : PEP8 --- donation/donation.py | 29 ++++++++++++++++++++--------- donation/donation_view.xml | 13 ++++++++++++- donation/report/donation_report.py | 8 +++----- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 960e37a11..10f98b1b5 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -47,6 +47,12 @@ class donation_donation(orm.Model): _description = 'Donations' _order = 'id desc' _rec_name = 'number' + _inherit = ['mail.thread'] + _track = { + 'state': { + 'donation.donation_done': + lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done'} + } def _compute_total(self, cr, uid, ids, name, arg, context=None): if context is None: @@ -79,10 +85,12 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): _columns = { 'currency_id': fields.many2one( 'res.currency', 'Currency', required=True, - states={'done': [('readonly', True)]}), + states={'done': [('readonly', True)]}, + track_visibility='onchange'), 'partner_id': fields.many2one( 'res.partner', 'Donor', required=True, - states={'done': [('readonly', True)]}), + states={'done': [('readonly', True)]}, + track_visibility='onchange'), # country_id is here to have stats per country # We don't want an invalidation function, because if the partner # moves to another country, we want to keep the old country for @@ -92,7 +100,8 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): relation='res.country', store=True), 'check_total': fields.float( 'Check Amount', digits_compute=dp.get_precision('Account'), - states={'done': [('readonly', True)]}), + states={'done': [('readonly', True)]}, + track_visibility='onchange'), 'amount_total': fields.function( _compute_total, type='float', multi="donation", string='Amount Total', store={ @@ -112,7 +121,8 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): }), 'donation_date': fields.date( 'Donation Date', required=True, - states={'done': [('readonly', True)]}), + states={'done': [('readonly', True)]}, + track_visibility='onchange'), 'company_id': fields.many2one( 'res.company', 'Company', required=True, states={'done': [('readonly', True)]}), @@ -129,20 +139,22 @@ def _get_donation_from_lines(self, cr, uid, ids, context=None): domain=[ ('type', 'in', ('bank', 'cash')), ('allow_donation', '=', True)], - states={'done': [('readonly', True)]}), + states={'done': [('readonly', True)]}, + track_visibility='onchange'), 'payment_ref': fields.char( 'Payment Reference', size=32, states={'done': [('readonly', True)]}), 'state': fields.selection([ ('draft', 'Draft'), ('done', 'Done'), - ], 'State', readonly=True, copy='draft'), + ], 'State', readonly=True, copy='draft', + track_visibility='onchange'), 'company_currency_id': fields.related( 'company_id', 'currency_id', type='many2one', relation="res.currency", string="Company Currency"), 'campaign_id': fields.many2one( - 'donation.campaign', 'Donation Campaign'), - 'create_uid': fields.many2one('res.users', 'Created by'), + 'donation.campaign', 'Donation Campaign', + track_visibility='onchange'), } def default_get(self, cr, uid, fields_list, context=None): @@ -317,7 +329,6 @@ def validate(self, cr, uid, ids, context=None): _("Cannot validate the donation of %s because it is not " "in draft state.") % donation.partner_id.name) - if donation.check_total != donation.amount_total: raise orm.except_orm( _('Error:'), diff --git a/donation/donation_view.xml b/donation/donation_view.xml index b99496310..93a2843bf 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -49,12 +49,15 @@ - +
+ + +
@@ -167,5 +170,13 @@ + + + Donation Validated + donation.donation + + Donation Validated + + diff --git a/donation/report/donation_report.py b/donation/report/donation_report.py index 90ec4446f..15b16541a 100644 --- a/donation/report/donation_report.py +++ b/donation/report/donation_report.py @@ -89,8 +89,6 @@ def _group_by(self): def init(self, cr): tools.drop_view_if_exists(cr, self._table) - cr.execute( - """CREATE OR REPLACE VIEW %s AS ( - %s FROM %s %s %s)""" % ( - self._table, self._select(), self._from(), - self._where(), self._group_by())) + cr.execute("CREATE OR REPLACE VIEW %s AS (%s FROM %s %s %s)" % ( + self._table, self._select(), self._from(), + self._where(), self._group_by())) From 3ee7221ea71d65683e076b5f6fb1d95a3db27a2d Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 23 Dec 2014 01:44:41 +0100 Subject: [PATCH 045/172] Port to new API Add default donation tax receipt report Small usability enhancements --- donation/__openerp__.py | 1 - donation/donation.py | 622 ++++++++++++--------------- donation/donation_campaign.py | 33 +- donation/donation_demo.xml | 2 +- donation/donation_view.xml | 23 +- donation/product.py | 34 +- donation/product_view.xml | 4 +- donation/wizard/donation_validate.py | 22 +- 8 files changed, 326 insertions(+), 415 deletions(-) diff --git a/donation/__openerp__.py b/donation/__openerp__.py index feb8313e2..28273ca47 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -53,5 +53,4 @@ 'product_demo.xml', 'donation_demo.xml', ], - 'active': False, } diff --git a/donation/donation.py b/donation/donation.py index 10f98b1b5..4e8807616 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -19,30 +19,26 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields, api, _ +from openerp.exceptions import Warning import openerp.addons.decimal_precision as dp -from openerp.tools.translate import _ -from openerp.tools import DEFAULT_SERVER_DATE_FORMAT -from datetime import datetime -class res_users(orm.Model): +class ResUsers(models.Model): _inherit = 'res.users' - _columns = { - 'context_donation_campaign_id': fields.many2one( - 'donation.campaign', 'Current Donation Campaign'), - 'context_donation_journal_id': fields.property( - type='many2one', relation='account.journal', - string='Current Donation Payment Method', - domain=[ - ('type', 'in', ('bank', 'cash')), - ('allow_donation', '=', True)]), + context_donation_campaign_id = fields.Many2one( + 'donation.campaign', string='Current Donation Campaign') + context_donation_journal_id = fields.Many2one( + 'account.journal', string='Current Donation Payment Method', + domain=[ + ('type', 'in', ('bank', 'cash')), + ('allow_donation', '=', True)], + company_dependent=True) # begin with context_ to allow user to change it by itself - } -class donation_donation(orm.Model): +class DonationDonation(models.Model): _name = 'donation.donation' _description = 'Donations' _order = 'id desc' @@ -51,202 +47,145 @@ class donation_donation(orm.Model): _track = { 'state': { 'donation.donation_done': - lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done'} + lambda self, cr, uid, obj, ctx=None: obj.state == 'done'} } - def _compute_total(self, cr, uid, ids, name, arg, context=None): - if context is None: - context = {} - res = {} # key = ID, value : amount_total - for donation in self.browse(cr, uid, ids, context=context): - total = 0.0 - for line in donation.line_ids: - total += line.quantity * line.unit_price - if donation.currency_id == donation.company_id.currency_id: - total_company_currency = total - else: - ctx_convert = context.copy() - ctx_convert['date'] = donation.donation_date - total_company_currency = self.pool['res.currency'].compute( - cr, uid, donation.currency_id.id, - donation.company_id.currency_id.id, total, - context=ctx_convert) - res[donation.id] = { - 'amount_total': total, - 'amount_total_company_currency': total_company_currency, - } - return res - - def _get_donation_from_lines(self, cr, uid, ids, context=None): - res = self.pool['donation.donation'].search( - cr, uid, [('line_ids', 'in', ids)], context=context) - return res - - _columns = { - 'currency_id': fields.many2one( - 'res.currency', 'Currency', required=True, - states={'done': [('readonly', True)]}, - track_visibility='onchange'), - 'partner_id': fields.many2one( - 'res.partner', 'Donor', required=True, - states={'done': [('readonly', True)]}, - track_visibility='onchange'), - # country_id is here to have stats per country - # We don't want an invalidation function, because if the partner - # moves to another country, we want to keep the old country for - # past donations - 'country_id': fields.related( - 'partner_id', 'country_id', type='many2one', - relation='res.country', store=True), - 'check_total': fields.float( - 'Check Amount', digits_compute=dp.get_precision('Account'), - states={'done': [('readonly', True)]}, - track_visibility='onchange'), - 'amount_total': fields.function( - _compute_total, type='float', multi="donation", - string='Amount Total', store={ - 'donation.line': ( - _get_donation_from_lines, - ['unit_price', 'quantity', 'donation_id'], 10), - }), - 'amount_total_company_currency': fields.function( - _compute_total, type='float', multi="donation", - string='Amount Total in Company Currency', store={ - 'donation.donation': ( - lambda self, cr, uid, ids, c={}: ids, - ['currency_id', 'journal_id'], 10), - 'donation.line': ( - _get_donation_from_lines, - ['unit_price', 'quantity', 'donation_id'], 20), - }), - 'donation_date': fields.date( - 'Donation Date', required=True, - states={'done': [('readonly', True)]}, - track_visibility='onchange'), - 'company_id': fields.many2one( - 'res.company', 'Company', required=True, - states={'done': [('readonly', True)]}), - 'line_ids': fields.one2many( - 'donation.line', 'donation_id', 'Donation Lines', - states={'done': [('readonly', True)]}, copy=True), - 'move_id': fields.many2one( - 'account.move', 'Account Move', readonly=True, copy=False), - 'number': fields.related( - 'move_id', 'name', type='char', readonly=True, size=64, - relation='account.move', store=True, string='Donation Number'), - 'journal_id': fields.many2one( - 'account.journal', 'Payment Method', required=True, - domain=[ - ('type', 'in', ('bank', 'cash')), - ('allow_donation', '=', True)], - states={'done': [('readonly', True)]}, - track_visibility='onchange'), - 'payment_ref': fields.char( - 'Payment Reference', size=32, - states={'done': [('readonly', True)]}), - 'state': fields.selection([ - ('draft', 'Draft'), - ('done', 'Done'), - ], 'State', readonly=True, copy='draft', - track_visibility='onchange'), - 'company_currency_id': fields.related( - 'company_id', 'currency_id', type='many2one', - relation="res.currency", string="Company Currency"), - 'campaign_id': fields.many2one( - 'donation.campaign', 'Donation Campaign', - track_visibility='onchange'), - } - - def default_get(self, cr, uid, fields_list, context=None): - res = super(donation_donation, self).default_get( - cr, uid, fields_list, context=context) - user = self.pool['res.users'].browse(cr, uid, uid, context=context) - company_id = self.pool['res.company']._company_default_get( - cr, uid, 'donation.donation', context=context) - company = self.pool['res.company'].browse( - cr, uid, company_id, context=context) - res.update({ - 'state': 'draft', - 'journal_id': user.context_donation_journal_id.id or False, - 'campaign_id': user.context_donation_campaign_id.id or False, - 'company_id': company_id, - 'currency_id': company.currency_id.id, - }) - return res - - def _check_donation_date(self, cr, uid, ids): - # I don't have the context, so I can't use fields.date.context_today - today_dt = datetime.today() - today_str = today_dt.strftime(DEFAULT_SERVER_DATE_FORMAT) - for donation in self.browse(cr, uid, ids): - if donation.donation_date > today_str: - raise orm.except_orm( - _('Error:'), - _('The date of the donation of %s should be today ' - 'or in the past, not in the future!') - % donation.partner_id.name) - return True - - _constraints = [( - _check_donation_date, - "Error on Donation Date", - ['donation_date'] - )] - - def _get_analytic_account_id( - self, cr, uid, donation_line, account_id, context=None): - analytic_account_id = donation_line.analytic_account_id.id or False - return analytic_account_id - - def _prepare_move_line_name(self, cr, uid, donation, context=None): - name = _('Donation of %s') % donation.partner_id.name + @api.one + @api.depends( + 'line_ids', 'line_ids.unit_price', 'line_ids.quantity', + 'donation_date', 'currency_id', 'company_id') + def _compute_total(self): + total = 0.0 + for line in self.line_ids: + total += line.quantity * line.unit_price + self.amount_total = total + donation_currency =\ + self.currency_id.with_context(date=self.donation_date) + total_company_currency = donation_currency.compute( + total, self.company_id.currency_id) + self.amount_total_company_currency = total_company_currency + + @api.model + def _default_currency(self): + company_id = self.env['res.company']._company_default_get( + 'donation.donation') + return self.env['res.company'].browse(company_id).currency_id + + currency_id = fields.Many2one( + 'res.currency', string='Currency', required=True, + states={'done': [('readonly', True)]}, + track_visibility='onchange', ondelete='restrict', + default=_default_currency) + partner_id = fields.Many2one( + 'res.partner', string='Donor', required=True, + states={'done': [('readonly', True)]}, + track_visibility='onchange', ondelete='restrict') + # country_id is here to have stats per country + # We don't want an invalidation function, because if the partner + # moves to another country, we want to keep the old country for + # past donations + country_id = fields.Many2one( + 'res.country', string='Country', related='partner_id.country_id', + store=True) + check_total = fields.Float( + string='Check Amount', digits_compute=dp.get_precision('Account'), + states={'done': [('readonly', True)]}, + track_visibility='onchange') + amount_total = fields.Float( + compute='_compute_total', string='Amount Total', store=True, + digits_compute=dp.get_precision('Account'), readonly=True) + amount_total_company_currency = fields.Float( + compute='_compute_total', string='Amount Total in Company Currency', + store=True, digits_compute=dp.get_precision('Account'), readonly=True) + donation_date = fields.Date( + string='Donation Date', required=True, + states={'done': [('readonly', True)]}, + track_visibility='onchange') + company_id = fields.Many2one( + 'res.company', string='Company', required=True, + states={'done': [('readonly', True)]}, + default=lambda self: self.env['res.company']._company_default_get( + 'donation.donation')) + line_ids = fields.One2many( + 'donation.line', 'donation_id', string='Donation Lines', + states={'done': [('readonly', True)]}, copy=True) + move_id = fields.Many2one( + 'account.move', string='Account Move', readonly=True, copy=False) + number = fields.Char( + related='move_id.name', readonly=True, size=64, + store=True, string='Donation Number') + journal_id = fields.Many2one( + 'account.journal', string='Payment Method', required=True, + domain=[ + ('type', 'in', ('bank', 'cash')), + ('allow_donation', '=', True)], + states={'done': [('readonly', True)]}, + track_visibility='onchange', + default=lambda self: self.env.user.context_donation_journal_id) + payment_ref = fields.Char( + string='Payment Reference', size=32, + states={'done': [('readonly', True)]}) + state = fields.Selection([ + ('draft', 'Draft'), + ('done', 'Done'), + ], string='State', readonly=True, copy='draft', default='draft', + track_visibility='onchange') + company_currency_id = fields.Many2one( + related='company_id.currency_id', string="Company Currency") + campaign_id = fields.Many2one( + 'donation.campaign', string='Donation Campaign', + track_visibility='onchange', ondelete='restrict', + default=lambda self: self.env.user.context_donation_campaign_id) + + @api.one + @api.constrains('donation_date') + def _check_donation_date(self): + if self.donation_date > fields.Date.context_today(self): + raise Warning( + _('The date of the donation of %s should be today ' + 'or in the past, not in the future!') + % self.partner_id.name) + + @api.model + def _prepare_move_line_name(self): + name = _('Donation of %s') % self.partner_id.name return name - def _prepare_donation_move(self, cr, uid, donation, context=None): - if context is None: - context = {} - - if not donation.journal_id.default_debit_account_id: - raise orm.except_orm( - _('Error:'), + @api.model + def _prepare_donation_move(self): + if not self.journal_id.default_debit_account_id: + raise Warning( _("Missing Default Debit Account on journal '%s'.") - % donation.journal_id.name) + % self.journal_id.name) - context['account_period_prefer_normal'] = True - period_search = self.pool['account.period'].find( - cr, uid, donation.donation_date, context=context) - assert len(period_search) == 1, 'We should get one period' - period_id = period_search[0] + period = self.env['account.period'].find(dt=self.donation_date) movelines = [] - if donation.company_id.currency_id.id != donation.currency_id.id: - currency_id = donation.currency_id.id + if self.company_id.currency_id.id != self.currency_id.id: + currency_id = self.currency_id.id else: currency_id = False # Note : we can have negative donations for donors that use direct # debit when their direct debit rejected by the bank amount_total_company_cur = 0.0 total_amount_currency = 0.0 - name = self._prepare_move_line_name( - cr, uid, donation, context=context) + name = self._prepare_move_line_name() aml = {} # key = (account_id, analytic_account_id) # value = {'credit': ..., 'debit': ..., 'amount_currency': ...} - for donation_line in donation.line_ids: + for donation_line in self.line_ids: amount_total_company_cur += donation_line.amount_company_currency account_id = donation_line.product_id.property_account_income.id if not account_id: account_id = donation_line.product_id.categ_id.\ property_account_income_categ.id if not account_id: - raise orm.except_orm( - _('Error:'), + raise Warning( _("Missing income account on product '%s' or on it's " "related product category") % donation_line.product_id.name) - analytic_account_id = self._get_analytic_account_id( - cr, uid, donation_line, account_id, context=context) + analytic_account_id = donation_line.get_analytic_account_id() amount_currency = 0.0 if donation_line.amount_company_currency > 0: credit = donation_line.amount_company_currency @@ -258,6 +197,9 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): amount_currency = donation_line.amount # TODO Take into account the option group_invoice_lines ? + print "aml=", aml + print "account=", account_id + print "ana account=", analytic_account_id if (account_id, analytic_account_id) in aml: aml[(account_id, analytic_account_id)]['credit'] += credit aml[(account_id, analytic_account_id)]['debit'] += debit @@ -277,7 +219,7 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): 'debit': content['debit'], 'account_id': account_id, 'analytic_account_id': analytic_account_id, - 'partner_id': donation.partner_id.id, + 'partner_id': self.partner_id.id, 'currency_id': currency_id, 'amount_currency': ( currency_id and content['amount_currency'] or 0.0), @@ -287,224 +229,190 @@ def _prepare_donation_move(self, cr, uid, donation, context=None): if amount_total_company_cur > 0: debit = amount_total_company_cur credit = 0 - total_amount_currency = donation.amount_total + total_amount_currency = self.amount_total else: credit = amount_total_company_cur * -1 debit = 0 - total_amount_currency = donation.amount_total * -1 + total_amount_currency = self.amount_total * -1 movelines.append( (0, 0, { 'debit': debit, 'credit': credit, 'name': name, - 'account_id': donation.journal_id.default_debit_account_id.id, - 'partner_id': donation.partner_id.id, + 'account_id': self.journal_id.default_debit_account_id.id, + 'partner_id': self.partner_id.id, 'currency_id': currency_id, 'amount_currency': ( currency_id and total_amount_currency or 0.0), })) vals = { - 'journal_id': donation.journal_id.id, - 'date': donation.donation_date, - 'period_id': period_id, - 'ref': donation.payment_ref, + 'journal_id': self.journal_id.id, + 'date': self.donation_date, + 'period_id': period.id, + 'ref': self.payment_ref, 'line_id': movelines, } return vals - def validate(self, cr, uid, ids, context=None): - assert len(ids) == 1, 'Only one ID accepted' - donation = self.browse(cr, uid, ids[0], context=context) - - if not donation.line_ids: - raise orm.except_orm( - _('Error:'), + @api.one + def validate(self): + if not self.line_ids: + raise Warning( _("Cannot validate the donation of %s because it doesn't " - "have any lines!") % donation.partner_id.name) + "have any lines!") % self.partner_id.name) - if donation.state != 'draft': - raise orm.except_orm( - _('Error:'), + if self.state != 'draft': + raise Warning( _("Cannot validate the donation of %s because it is not " - "in draft state.") % donation.partner_id.name) + "in draft state.") % self.partner_id.name) - if donation.check_total != donation.amount_total: - raise orm.except_orm( - _('Error:'), + if ( + self.env['res.users'].has_group( + 'account.group_supplier_inv_check_total') + and self.check_total != self.amount_total): + raise Warning( _("The amount of the donation of %s (%s) is different from " "the sum of the donation lines (%s).") % ( - donation.partner_id.name, donation.check_total, - donation.amount_total)) + self.partner_id.name, self.check_total, + self.amount_total)) donation_write_vals = {'state': 'done'} - if donation.amount_total: - move_vals = self._prepare_donation_move( - cr, uid, donation, context=context) - move_id = self.pool['account.move'].create( - cr, uid, move_vals, context=context) - - self.pool['account.move'].post(cr, uid, [move_id], context=context) - donation_write_vals['move_id'] = move_id - - self.write(cr, uid, donation.id, donation_write_vals, context=context) - return True - - def partner_id_change( - self, cr, uid, ids, partner_id, company_id, context=None): - return {} - - def save_default_values(self, cr, uid, ids, context=None): - assert len(ids) == 1, 'Only 1 ID' - donation = self.browse(cr, uid, ids[0], context=context) - self.pool['res.users'].write( - cr, uid, uid, { - 'context_donation_journal_id': - donation.journal_id.id or False, - 'context_donation_campaign_id': - donation.campaign_id.id or False, - }, context=context) + if self.amount_total: + move_vals = self._prepare_donation_move() + print "move_vals=", move_vals + move = self.env['account.move'].create(move_vals) + move.post() + donation_write_vals['move_id'] = move.id + + self.write(donation_write_vals) + return + + @api.one + def save_default_values(self): + self.env.user.write({ + 'context_donation_journal_id': self.journal_id.id, + 'context_donation_campaign_id': self.campaign_id.id, + }) + return + + @api.one + def back_to_draft(self): + if self.move_id: + self.move_id.button_cancel() + self.move_id.unlink() + self.state = 'draft' return - def back_to_draft(self, cr, uid, ids, context=None): - assert len(ids) == 1, 'only one ID for back2draft' - donation = self.browse(cr, uid, ids[0], context=context) - if donation.move_id: - self.pool['account.move'].button_cancel( - cr, uid, [donation.move_id.id], context=context) - self.pool['account.move'].unlink( - cr, uid, donation.move_id.id, context=context) - donation.write({'state': 'draft'}) - return True - - def unlink(self, cr, uid, ids, context=None): - for donation in self.browse(cr, uid, ids, context=context): + @api.multi + def unlink(self): + for donation in self: if donation.state == 'done': - raise orm.except_orm( - _('Error:'), + raise Warning( _("The donation '%s' is in Done state, so you must " "set it back to draft before deleting it.") % donation.number) - return super(donation_donation, self).unlink( - cr, uid, ids, context=context) - - -class donation_line(orm.Model): - _name = 'donation.line' - _description = 'Donation Lines' - _rec_name = 'product_id' - - def _compute_amount(self, cr, uid, ids, name, arg, context=None): - res = {} - for line in self.browse(cr, uid, ids, context=context): - amount = line.quantity * line.unit_price - company_cur_id = line.donation_id.company_id.currency_id.id - donation_cur_id = line.donation_id.currency_id.id - if company_cur_id == donation_cur_id: - amount_company_currency = amount + return super(DonationDonation, self).unlink() + + @api.multi + @api.depends('state', 'partner_id', 'move_id') + def name_get(self): + res = [] + for donation in self: + if donation.state == 'draft': + name = _('Draft Donation of %s') % donation.partner_id.name else: - ctx_convert = context.copy() - ctx_convert['date'] = line.donation_id.donation_date - amount_company_currency = self.pool['res.currency'].compute( - cr, uid, donation_cur_id, company_cur_id, amount, - context=ctx_convert) - res[line.id] = { - 'amount': amount, - 'amount_company_currency': amount_company_currency, - } + name = donation.number + res.append((donation.id, name)) return res - def _get_lines_from_donation(self, cr, uid, ids, context=None): - return self.pool['donation.line'].search( - cr, uid, [('donation_id', 'in', ids)], context=context) - - _columns = { - 'donation_id': fields.many2one( - 'donation.donation', 'Donation', ondelete='cascade'), - 'product_id': fields.many2one( - 'product.product', 'Product', required=True, - domain=[('donation', '=', True)]), - 'quantity': fields.integer('Quantity'), - 'unit_price': fields.float( - 'Unit Price', digits_compute=dp.get_precision('Account')), - 'amount': fields.function( - _compute_amount, multi="donline", type="float", string='Amount', - digits_compute=dp.get_precision('Account'), store={ - 'donation.line': ( - lambda self, cr, uid, ids, c={}: ids, - ['quantity', 'unit_price'], 10), - }), - 'amount_company_currency': fields.function( - _compute_amount, multi="donline", type="float", - string='Amount in Company Currency', - digits_compute=dp.get_precision('Account'), store={ - 'donation.line': ( - lambda self, cr, uid, ids, c={}: ids, - ['quantity', 'unit_price'], 10), - 'donation.donation': ( - _get_lines_from_donation, - ['journal_id', 'currency_id'], 10), - }), - 'analytic_account_id': fields.many2one( - 'account.analytic.account', 'Analytic Account', - domain=[('type', 'not in', ('view', 'template'))]), - 'sequence': fields.integer('Sequence'), - } - - _defaults = { - 'quantity': 1, - } + # used by module donation_tax_receipt (and donation_stay) + @api.onchange('partner_id') + def partner_id_change(self): + return - def product_id_change(self, cr, uid, ids, product_id, context=None): - res = {'value': {}} - if product_id: - product = self.pool['product.product'].browse( - cr, uid, product_id, context=context) - res['value']['unit_price'] = product.list_price - return res +class DonationLine(models.Model): + _name = 'donation.line' + _description = 'Donation Lines' + _rec_name = 'product_id' -class res_partner(orm.Model): + @api.one + @api.depends('unit_price', 'quantity') + def _compute_amount(self): + amount = self.quantity * self.unit_price + self.amount = amount + + @api.one + @api.depends( + 'unit_price', 'quantity', 'donation_id.currency_id', + 'donation_id.donation_date', 'donation_id.company_id') + def _compute_amount_company_currency(self): + amount = self.quantity * self.unit_price + donation_currency = self.donation_id.currency_id.with_context( + date=self.donation_id.donation_date) + self.amount_company_currency = donation_currency.compute( + amount, self.donation_id.company_id.currency_id) + + donation_id = fields.Many2one( + 'donation.donation', string='Donation', ondelete='cascade') + product_id = fields.Many2one( + 'product.product', string='Product', required=True, + domain=[('donation', '=', True)], ondelete='restrict') + quantity = fields.Integer(string='Quantity', default=1) + unit_price = fields.Float( + string='Unit Price', digits_compute=dp.get_precision('Account')) + amount = fields.Float( + compute='_compute_amount', string='Amount', + digits_compute=dp.get_precision('Account'), store=True) + amount_company_currency = fields.Float( + compute='_compute_amount_company_currency', + string='Amount in Company Currency', + digits_compute=dp.get_precision('Account'), store=True) + analytic_account_id = fields.Many2one( + 'account.analytic.account', string='Analytic Account', + domain=[('type', 'not in', ('view', 'template'))], ondelete='restrict') + sequence = fields.Integer('Sequence') + + @api.onchange('product_id') + def product_id_change(self): + if self.product_id and self.product_id.list_price: + self.unit_price = self.product_id.list_price + + @api.model + def get_analytic_account_id(self): + return self.analytic_account_id.id or False + + +class ResPartner(models.Model): _inherit = 'res.partner' - def _donation_count(self, cr, uid, ids, field_name, arg, context=None): - res = dict(map(lambda x: (x, 0), ids)) + @api.one + @api.depends('donation_ids') + def _donation_count(self): # The current user may not have access rights for donations try: - for partner in self.browse(cr, uid, ids, context): - res[partner.id] = len(partner.donation_ids) + self.donation_count = len(self.donation_ids) except: - pass - return res + self.donation_count = 0 - _columns = { - 'donation_ids': fields.one2many( - 'donation.donation', 'partner_id', 'Donations', copy=False), - 'donation_count': fields.function( - _donation_count, string="# of Donations", type='integer'), - } + donation_ids = fields.One2many( + 'donation.donation', 'partner_id', string='Donations', copy=False) + donation_count = fields.Integer( + compute='_donation_count', string="# of Donations", readonly=True) -class account_journal(orm.Model): +class account_journal(models.Model): _inherit = 'account.journal' - _columns = { - 'allow_donation': fields.boolean('Donation Payment Method'), - } + allow_donation = fields.Boolean(string='Donation Payment Method') - def _check_donation(self, cr, uid, ids): - for journal in self.browse(cr, uid, ids): - if journal.allow_donation and journal.type not in ('bank', 'cash'): - raise orm.except_orm( - _('Error:'), - _("The journal '%s' has the option 'Allow Donation', " - "so it's type should be 'Cash' or 'Bank and Checks.") - % journal.name) - return True - - _constraints = [( - _check_donation, - 'Wrong configuration of journal', - ['type', 'allow_donation'] - )] + @api.one + @api.constrains('type', 'allow_donation') + def _check_donation(self): + if self.allow_donation and self.type not in ('bank', 'cash'): + raise Warning( + _("The journal '%s' has the option 'Allow Donation', " + "so it's type should be 'Cash' or 'Bank and Checks.") + % self.name) diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py index 0705f33e2..8aca6acda 100644 --- a/donation/donation_campaign.py +++ b/donation/donation_campaign.py @@ -19,33 +19,28 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields, api -class donation_campaign(orm.Model): +class donation_campaign(models.Model): _name = 'donation.campaign' _description = 'Code attributed for a Donation Campaign' _order = 'code' - def name_get(self, cr, uid, ids, context=None): + @api.multi + @api.depends('code', 'name') + def name_get(self): res = [] - if isinstance(ids, (int, long)): - ids = [ids] - for record in self.browse(cr, uid, ids, context=context): + for record in self: if record.code: - res.append( - (record.id, u'[%s] %s' % (record.code, record.name))) + name = u'[%s] %s' % (record.code, record.name) else: - res.append((record.id, record.name)) + name = record.name + res.append((record.id, name)) return res - _columns = { - 'code': fields.char('Code', size=10), - 'name': fields.char('Name', size=64, required=True), - 'start_date': fields.date('Start Date'), - 'nota': fields.text('Notes'), - } - - _defaults = { - 'start_date': fields.date.context_today, - } + code = fields.Char(string='Code', size=10) + name = fields.Char('Name', required=True) + start_date = fields.Date( + string='Start Date', default=fields.Date.context_today) + nota = fields.Text(string='Notes') diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index a08fdc9bb..587245ff0 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -37,7 +37,7 @@ Lucie Dubois 34 rue Pierre Dupont - 69004 + 69001 Lyon lucie.dubois@yahoo.example.com diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 93a2843bf..e3d919738 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -25,31 +25,40 @@ + options="{'currency_field': 'currency_id'}" + groups="account.group_supplier_inv_check_total"/> - + + + + + + + @@ -119,7 +128,7 @@ - + @@ -136,7 +145,7 @@
- + diff --git a/donation/product.py b/donation/product.py index 8e86b9b6b..4e0fcc714 100644 --- a/donation/product.py +++ b/donation/product.py @@ -19,29 +19,29 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields, api -class product_template(orm.Model): +class ProductTemplate(models.Model): _inherit = 'product.template' - _columns = { - 'donation': fields.boolean( - 'Is a Donation', - help="Specify if the product can be selected " - "in a donation line."), - } + donation = fields.Boolean( + string='Is a Donation', + help="Specify if the product can be selected " + "in a donation line.") - def donation_change(self, cr, uid, ids, donation, context=None): - res = {'value': {}} - if donation: - res['value'] = {'type': 'service', 'sale_ok': False} - return res + @api.onchange('donation') + def _donation_change(self): + if self.donation: + self.type = 'service' + self.sale_ok = False -class product_product(orm.Model): +class ProductProduct(models.Model): _inherit = 'product.product' - def donation_change(self, cr, uid, ids, donation, context=None): - return self.pool['product.template'].donation_change( - cr, uid, [], donation, context=context) + @api.onchange('donation') + def _donation_change(self): + if self.donation: + self.type = 'service' + self.sale_ok = False diff --git a/donation/product_view.xml b/donation/product_view.xml index 5107f2c86..57c1bdcc1 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -21,7 +21,7 @@
- +
@@ -32,7 +32,7 @@ Products product.template kanban,tree,form - {'search_default_filter_donation': 1} + {'search_default_filter_donation': 1, 'default_donation': 1} diff --git a/donation/wizard/donation_validate.py b/donation/wizard/donation_validate.py index 44fcc7beb..e31c2981d 100644 --- a/donation/wizard/donation_validate.py +++ b/donation/wizard/donation_validate.py @@ -3,6 +3,7 @@ # # Donation module for Odoo # Copyright (C) 2014 Barroux Abbey (www.barroux.org) +# @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -19,20 +20,19 @@ # ############################################################################## -from openerp.osv import orm +from openerp import models, api -class donation_validate(orm.TransientModel): +class DonationValidate(models.TransientModel): _name = 'donation.validate' _description = 'Validate Donations' - def run(self, cr, uid, ids, context=None): - if context is None: - context = {} - assert context.get('active_model') == 'donation.donation',\ + @api.one + def run(self): + assert self.env.context.get('active_model') == 'donation.donation',\ 'Source model must be donations' - assert context.get('active_ids'), 'No donation selected' - for donation_id in context['active_ids']: - self.pool['donation.donation'].validate( - cr, uid, [donation_id], context=context) - return True + assert self.env.context.get('active_ids'), 'No donations selected' + donations = self.env['donation.donation'].browse( + self.env.context.get('active_ids')) + donations.validate() + return From 97d8ca018950e98d8ea416b7086980bcd5e97024 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 23 Dec 2014 23:15:57 +0100 Subject: [PATCH 046/172] Port donation_bank_statement to the new API Add demo data in module donation_bank_statement Remove debug print --- donation/donation.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 4e8807616..685337f5b 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -197,9 +197,6 @@ def _prepare_donation_move(self): amount_currency = donation_line.amount # TODO Take into account the option group_invoice_lines ? - print "aml=", aml - print "account=", account_id - print "ana account=", analytic_account_id if (account_id, analytic_account_id) in aml: aml[(account_id, analytic_account_id)]['credit'] += credit aml[(account_id, analytic_account_id)]['debit'] += debit @@ -281,7 +278,6 @@ def validate(self): if self.amount_total: move_vals = self._prepare_donation_move() - print "move_vals=", move_vals move = self.env['account.move'].create(move_vals) move.post() donation_write_vals['move_id'] = move.id From b32053b909cf840b34478b9a9b0f3d8ff7c1dce7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 30 Dec 2014 11:04:13 +0100 Subject: [PATCH 047/172] Add readonly=True on all related fields, to avoid access right issues --- donation/donation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 685337f5b..ffa6088c0 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -86,7 +86,7 @@ def _default_currency(self): # past donations country_id = fields.Many2one( 'res.country', string='Country', related='partner_id.country_id', - store=True) + store=True, readonly=True) check_total = fields.Float( string='Check Amount', digits_compute=dp.get_precision('Account'), states={'done': [('readonly', True)]}, @@ -131,7 +131,8 @@ def _default_currency(self): ], string='State', readonly=True, copy='draft', default='draft', track_visibility='onchange') company_currency_id = fields.Many2one( - related='company_id.currency_id', string="Company Currency") + related='company_id.currency_id', string="Company Currency", + readonly=True) campaign_id = fields.Many2one( 'donation.campaign', string='Donation Campaign', track_visibility='onchange', ondelete='restrict', From 686444f4d9615e1384f34a8ce8956a2e27a4270a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 11 Jan 2015 19:01:25 +0100 Subject: [PATCH 048/172] Add company_id in donation tree view --- donation/donation_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/donation/donation_view.xml b/donation/donation_view.xml index e3d919738..2d485cee9 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -83,6 +83,7 @@ + From ae07dda25ce6a94878213838f0e4724f12baf96f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 12 Jan 2015 14:30:56 +0100 Subject: [PATCH 049/172] FIX in multi-company setups copy= in field definition is a boolean --- donation/donation.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index ffa6088c0..fe13da424 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -65,6 +65,16 @@ def _compute_total(self): total, self.company_id.currency_id) self.amount_total_company_currency = total_company_currency + # We don't want a depends on partner_id.country_id, because if the partner + # moves to another country, we want to keep the old country for + # past donations + @api.one + @api.depends('partner_id') + def _compute_country_id(self): + # Use sudo() to by-pass record rules, because the same partner + # can have donations in several companies + self.sudo().country_id = self.partner_id.country_id or False + @api.model def _default_currency(self): company_id = self.env['res.company']._company_default_get( @@ -81,12 +91,13 @@ def _default_currency(self): states={'done': [('readonly', True)]}, track_visibility='onchange', ondelete='restrict') # country_id is here to have stats per country - # We don't want an invalidation function, because if the partner - # moves to another country, we want to keep the old country for - # past donations + # WARNING : I can't put a related field, because when someone + # writes on the country_id of a partner, it will trigger a write + # on all it's donations, including donations in other companies + # which will be blocked by the record rule country_id = fields.Many2one( - 'res.country', string='Country', related='partner_id.country_id', - store=True, readonly=True) + 'res.country', string='Country', compute='_compute_country_id', + store=True, readonly=True, copy=False) check_total = fields.Float( string='Check Amount', digits_compute=dp.get_precision('Account'), states={'done': [('readonly', True)]}, @@ -128,7 +139,7 @@ def _default_currency(self): state = fields.Selection([ ('draft', 'Draft'), ('done', 'Done'), - ], string='State', readonly=True, copy='draft', default='draft', + ], string='State', readonly=True, copy=False, default='draft', track_visibility='onchange') company_currency_id = fields.Many2one( related='company_id.currency_id', string="Company Currency", From 8a234081c3aa64599fdc839f8fe90bbc635472d4 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 13 Jan 2015 22:02:21 +0100 Subject: [PATCH 050/172] Auto-add demo user to user-level groups, for easier testing --- donation/donation_demo.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 587245ff0..45aa5d2e1 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -77,6 +77,9 @@ 120 + + + From d658b466ddc82ef79c810027ea03e9be344f7f00 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 16 Jan 2015 08:35:39 +0100 Subject: [PATCH 051/172] copy=False is the default on one2many fields Can't put a one2many field alone in a depends, from my experience of the new API --- donation/donation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index fe13da424..a2bd6f7ff 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -397,7 +397,7 @@ class ResPartner(models.Model): _inherit = 'res.partner' @api.one - @api.depends('donation_ids') + @api.depends('donation_ids.partner_id') def _donation_count(self): # The current user may not have access rights for donations try: @@ -406,7 +406,7 @@ def _donation_count(self): self.donation_count = 0 donation_ids = fields.One2many( - 'donation.donation', 'partner_id', string='Donations', copy=False) + 'donation.donation', 'partner_id', string='Donations') donation_count = fields.Integer( compute='_donation_count', string="# of Donations", readonly=True) From be68a38eed6d3da6e9c27791502e86010a4dc82f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 31 Jan 2015 00:56:16 +0100 Subject: [PATCH 052/172] stay: don't set refectory when no_meals option active on stay Add tests in stay and donation modules Update demo data --- donation/__openerp__.py | 1 + donation/donation_demo.xml | 29 +++++++++++++++++++++++++++ donation/test/validate.yml | 40 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 donation/test/validate.yml diff --git a/donation/__openerp__.py b/donation/__openerp__.py index 28273ca47..b192a8bd7 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -53,4 +53,5 @@ 'product_demo.xml', 'donation_demo.xml', ], + 'test': ['test/validate.yml'], } diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 45aa5d2e1..825c424bd 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -43,6 +43,17 @@ lucie.dubois@yahoo.example.com + + Joe Smith + + Craig Pond Trail + 04431 + East Orland + + + joe.smith@gmail.example.com + + 100 @@ -77,6 +88,24 @@ 120 + + + 150 + + + + + + + + + + + 1 + 150 + + + diff --git a/donation/test/validate.yml b/donation/test/validate.yml new file mode 100644 index 000000000..0f7e3ff18 --- /dev/null +++ b/donation/test/validate.yml @@ -0,0 +1,40 @@ +- + Validate donation1 +- + !function {model: donation.donation, name: validate}: + - eval: "[obj(ref('donation1')).id]" +- + Donation1 Check that an account move has been generated +- + !assert {model: donation.donation, id: donation1, string: Donation1 was not correctly validated}: + - state == 'done' + - move_id.date == time.strftime('%Y-%m-01') + - move_id.journal_id.id == ref('account.check_journal') + - move_id.state == 'posted' + - move_id.ref == 'CHQ BNP 239023' +- + Validate donation2 +- + !function {model: donation.donation, name: validate}: + - eval: "[obj(ref('donation2')).id]" +- + Donation2 Check that an account move has been generated +- + !assert {model: donation.donation, id: donation2, string: Donation2 was not correctly validated}: + - state == 'done' + - move_id.date == time.strftime('%Y-%m-01') + - move_id.journal_id.id == ref('account.cash_journal') + - move_id.state == 'posted' +- + Validate donation3 +- + !function {model: donation.donation, name: validate}: + - eval: "[obj(ref('donation3')).id]" +- + Donation3 Check that an account move has been generated +- + !assert {model: donation.donation, id: donation3, string: Donation3 was not correctly validated}: + - state == 'done' + - move_id.date == time.strftime('%Y-%m-01') + - move_id.journal_id.id == ref('account.cash_journal') + - move_id.state == 'posted' From 0fc4212f4390b1c4718b7ca68c4233f55e077758 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 31 Jan 2015 23:09:57 +0100 Subject: [PATCH 053/172] Add yaml test for annual tax receipts Move the content of donation/product_demo.xml inside donation/donation_demo.xml --- donation/__openerp__.py | 5 +---- donation/donation_demo.xml | 14 ++++++++++++++ donation/product_demo.xml | 20 -------------------- 3 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 donation/product_demo.xml diff --git a/donation/__openerp__.py b/donation/__openerp__.py index b192a8bd7..e7d47fcc1 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -49,9 +49,6 @@ 'report/donation_report_view.xml', 'wizard/donation_validate_view.xml', ], - 'demo': [ - 'product_demo.xml', - 'donation_demo.xml', - ], + 'demo': ['donation_demo.xml'], 'test': ['test/validate.yml'], } diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 825c424bd..86c9f26c6 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -3,6 +3,20 @@ + + + Donation + DON + + + 1 + 0 + service + + + This is a donation product. + + diff --git a/donation/product_demo.xml b/donation/product_demo.xml deleted file mode 100644 index bede4b4f7..000000000 --- a/donation/product_demo.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - Donation - DON - - - 1 - 0 - service - - - This is a donation product. - - - - From 2ddd621735f2495c8404b690fd1e8f221fb102ed Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 2 Feb 2015 01:40:46 +0100 Subject: [PATCH 054/172] Start to replace name_get by display_name (better use of new API) --- donation/donation.py | 22 +++++++++++----------- donation/donation_campaign.py | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index a2bd6f7ff..dbce7d8db 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -42,7 +42,7 @@ class DonationDonation(models.Model): _name = 'donation.donation' _description = 'Donations' _order = 'id desc' - _rec_name = 'number' + _rec_name = 'display_name' _inherit = ['mail.thread'] _track = { 'state': { @@ -148,6 +148,9 @@ def _default_currency(self): 'donation.campaign', string='Donation Campaign', track_visibility='onchange', ondelete='restrict', default=lambda self: self.env.user.context_donation_campaign_id) + display_name = fields.Char( + string='Display Name', compute='_compute_display_name', + readonly=True) @api.one @api.constrains('donation_date') @@ -323,17 +326,14 @@ def unlink(self): % donation.number) return super(DonationDonation, self).unlink() - @api.multi + @api.one @api.depends('state', 'partner_id', 'move_id') - def name_get(self): - res = [] - for donation in self: - if donation.state == 'draft': - name = _('Draft Donation of %s') % donation.partner_id.name - else: - name = donation.number - res.append((donation.id, name)) - return res + def _compute_display_name(self): + if self.state == 'draft': + name = _('Draft Donation of %s') % self.partner_id.name + else: + name = self.number + self.display_name = name # used by module donation_tax_receipt (and donation_stay) @api.onchange('partner_id') diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py index 8aca6acda..17579f896 100644 --- a/donation/donation_campaign.py +++ b/donation/donation_campaign.py @@ -26,21 +26,21 @@ class donation_campaign(models.Model): _name = 'donation.campaign' _description = 'Code attributed for a Donation Campaign' _order = 'code' + _rec_name = 'display_name' - @api.multi + @api.one @api.depends('code', 'name') - def name_get(self): - res = [] - for record in self: - if record.code: - name = u'[%s] %s' % (record.code, record.name) - else: - name = record.name - res.append((record.id, name)) - return res + def _compute_display_name(self): + name = self.name + if self.code: + name = u'[%s] %s' % (self.code, name) + self.display_name = name code = fields.Char(string='Code', size=10) - name = fields.Char('Name', required=True) + name = fields.Char(string='Name', required=True) + display_name = fields.Char( + string='Display Name', compute='_compute_display_name', + readonly=True, store=True) start_date = fields.Date( string='Start Date', default=fields.Date.context_today) nota = fields.Text(string='Notes') From a5eab4314857cb59c45366a4b34925a5af37fd86 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 17 Feb 2015 22:07:53 +0100 Subject: [PATCH 055/172] Add field Remaining offering, to control the amount in accouting. digits_compute= -> digits= in field definition Remove unused ODT file --- donation/donation.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index dbce7d8db..0dca3e526 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -99,15 +99,15 @@ def _default_currency(self): 'res.country', string='Country', compute='_compute_country_id', store=True, readonly=True, copy=False) check_total = fields.Float( - string='Check Amount', digits_compute=dp.get_precision('Account'), + string='Check Amount', digits=dp.get_precision('Account'), states={'done': [('readonly', True)]}, track_visibility='onchange') amount_total = fields.Float( compute='_compute_total', string='Amount Total', store=True, - digits_compute=dp.get_precision('Account'), readonly=True) + digits=dp.get_precision('Account'), readonly=True) amount_total_company_currency = fields.Float( compute='_compute_total', string='Amount Total in Company Currency', - store=True, digits_compute=dp.get_precision('Account'), readonly=True) + store=True, digits=dp.get_precision('Account'), readonly=True) donation_date = fields.Date( string='Donation Date', required=True, states={'done': [('readonly', True)]}, @@ -370,14 +370,14 @@ def _compute_amount_company_currency(self): domain=[('donation', '=', True)], ondelete='restrict') quantity = fields.Integer(string='Quantity', default=1) unit_price = fields.Float( - string='Unit Price', digits_compute=dp.get_precision('Account')) + string='Unit Price', digits=dp.get_precision('Account')) amount = fields.Float( compute='_compute_amount', string='Amount', - digits_compute=dp.get_precision('Account'), store=True) + digits=dp.get_precision('Account'), store=True) amount_company_currency = fields.Float( compute='_compute_amount_company_currency', string='Amount in Company Currency', - digits_compute=dp.get_precision('Account'), store=True) + digits=dp.get_precision('Account'), store=True) analytic_account_id = fields.Many2one( 'account.analytic.account', string='Analytic Account', domain=[('type', 'not in', ('view', 'template'))], ondelete='restrict') From 634297c4e593116059030670ebd188e553416a9f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 17 Feb 2015 23:54:39 +0100 Subject: [PATCH 056/172] Update POT/PO files Use fields.Date.from/to_string Fix bug in display_name method in donation_recurring --- donation/i18n/donation.pot | 300 ++++++++++++++++++++++++++++------ donation/i18n/fr.po | 320 +++++++++++++++++++++++++++++++------ 2 files changed, 518 insertions(+), 102 deletions(-) diff --git a/donation/i18n/donation.pot b/donation/i18n/donation.pot index 870fd5511..23c550fbc 100644 --- a/donation/i18n/donation.pot +++ b/donation/i18n/donation.pot @@ -1,13 +1,13 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: # * donation # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 8.0alpha1\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-07-01 12:46+0000\n" -"PO-Revision-Date: 2014-07-01 12:46+0000\n" +"POT-Creation-Date: 2015-02-17 22:34+0000\n" +"PO-Revision-Date: 2015-02-17 22:34+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,16 +15,6 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: donation -#: field:res.partner,donation_count:0 -msgid "# of Donations" -msgstr "" - -#. module: donation -#: field:res.partner,stay_count:0 -msgid "# of Stays" -msgstr "" - #. module: donation #: field:donation.donation,move_id:0 msgid "Account Move" @@ -61,15 +51,32 @@ msgid "Analytic Account" msgstr "" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_form msgid "Back to Draft" msgstr "" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_search msgid "Campaign" msgstr "" +#. module: donation +#: view:donation.validate:donation.donation_validate_form +msgid "Cancel" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:274 +#, python-format +msgid "Cannot validate the donation of %s because it doesn't have any lines!" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:279 +#, python-format +msgid "Cannot validate the donation of %s because it is not in draft state." +msgstr "" + #. module: donation #: field:donation.report,product_categ_id:0 msgid "Category of Product" @@ -92,27 +99,39 @@ msgstr "" #. module: donation #: field:donation.donation,company_id:0 -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_search #: field:donation.report,company_id:0 msgid "Company" msgstr "" #. module: donation -#: field:donation.donation,company_currency_id:0 -msgid "Company Currency" +#: model:ir.ui.menu,name:donation.donation_config_menu +msgid "Configuration" msgstr "" #. module: donation -#: model:ir.ui.menu,name:donation.donation_config_menu -msgid "Configuration" +#: field:donation.donation,country_id:0 +msgid "Country" msgstr "" #. module: donation +#: field:donation.campaign,create_uid:0 #: field:donation.donation,create_uid:0 +#: field:donation.line,create_uid:0 +#: field:donation.validate,create_uid:0 msgid "Created by" msgstr "" #. module: donation +#: field:donation.campaign,create_date:0 +#: field:donation.donation,create_date:0 +#: field:donation.line,create_date:0 +#: field:donation.validate,create_date:0 +msgid "Created on" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_search #: field:donation.donation,currency_id:0 msgid "Currency" msgstr "" @@ -123,34 +142,46 @@ msgid "Current Donation Campaign" msgstr "" #. module: donation -#: view:donation.donation:0 -#: view:donation.report:0 +#: field:res.users,context_donation_journal_id:0 +msgid "Current Donation Payment Method" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search msgid "Date" msgstr "" #. module: donation -#: constraint:donation.donation:0 -msgid "Date must be today or in the past" +#: help:donation.donation,message_last_post:0 +msgid "Date of the last message posted on the record." msgstr "" #. module: donation -#: view:donation.donation:0 +#: field:donation.campaign,display_name:0 +msgid "Display Name" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_form +#: view:donation.donation:donation.donation_tree #: field:donation.line,donation_id:0 #: model:ir.module.category,name:donation.module_category_donation -#: view:product.product:0 +#: view:product.template:donation.product_template_search_view +#: model:product.template,name:donation.product_product_donation_product_template msgid "Donation" msgstr "" #. module: donation -#: view:donation.campaign:0 +#: view:donation.campaign:donation.donation_campaign_form #: field:donation.donation,campaign_id:0 -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_search #: field:donation.report,campaign_id:0 msgid "Donation Campaign" msgstr "" #. module: donation -#: view:donation.campaign:0 +#: view:donation.campaign:donation.donation_campaign_tree #: model:ir.actions.act_window,name:donation.donation_campaign_action #: model:ir.ui.menu,name:donation.donation_campaign_menu msgid "Donation Campaigns" @@ -163,11 +194,13 @@ msgid "Donation Date" msgstr "" #. module: donation -#: view:donation.line:0 +#: view:donation.line:donation.donation_line_form +#: view:donation.line:donation.donation_line_tree msgid "Donation Line" msgstr "" #. module: donation +#: view:donation.donation:donation.donation_form #: field:donation.donation,line_ids:0 #: model:ir.model,name:donation.model_donation_line msgid "Donation Lines" @@ -179,7 +212,24 @@ msgid "Donation Number" msgstr "" #. module: donation -#: view:donation.donation:0 +#: field:account.journal,allow_donation:0 +msgid "Donation Payment Method" +msgstr "" + +#. module: donation +#: model:mail.message.subtype,description:donation.donation_done +#: model:mail.message.subtype,name:donation.donation_done +msgid "Donation Validated" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:166 +#, python-format +msgid "Donation of %s" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_graph #: model:ir.actions.act_window,name:donation.donation_action #: model:ir.actions.act_window,name:donation.partner_donation_action #: model:ir.model,name:donation.model_donation_donation @@ -187,13 +237,14 @@ msgstr "" #: model:ir.ui.menu,name:donation.donation_report_title_menu #: model:ir.ui.menu,name:donation.donation_title_menu #: model:ir.ui.menu,name:donation.donation_top_menu -#: view:res.partner:0 +#: view:res.partner:donation.view_partner_form #: field:res.partner,donation_ids:0 msgid "Donations" msgstr "" #. module: donation -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_graph +#: view:donation.report:donation.donation_report_search #: model:ir.actions.act_window,name:donation.donation_report_action #: model:ir.model,name:donation.model_donation_report #: model:ir.ui.menu,name:donation.donation_report_menu @@ -206,7 +257,7 @@ msgid "Donations Lines" msgstr "" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_search #: selection:donation.donation,state:0 msgid "Done" msgstr "" @@ -223,32 +274,83 @@ msgid "Donors" msgstr "" #. module: donation -#: model:product.category,name:donation.product_category_donation -msgid "Dons" +#: view:donation.donation:donation.donation_search +#: selection:donation.donation,state:0 +msgid "Draft" msgstr "" #. module: donation -#: view:donation.donation:0 -#: selection:donation.donation,state:0 -msgid "Draft" +#: code:addons/donation/donation.py:333 +#, python-format +msgid "Draft Donation of %s" msgstr "" #. module: donation -#: view:donation.donation:0 -#: view:donation.report:0 +#: field:donation.donation,message_follower_ids:0 +msgid "Followers" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search msgid "Group By" msgstr "" +#. module: donation +#: help:donation.donation,message_summary:0 +msgid "Holds the Chatter summary (number of messages, ...). This summary is directly in html format in order to be inserted in kanban views." +msgstr "" + +#. module: donation +#: field:donation.campaign,id:0 +#: field:donation.donation,id:0 +#: field:donation.line,id:0 +#: field:donation.report,id:0 +#: field:donation.validate,id:0 +msgid "ID" +msgstr "" + +#. module: donation +#: help:donation.donation,message_unread:0 +msgid "If checked new messages require your attention." +msgstr "" + #. module: donation #: field:product.template,donation:0 msgid "Is a Donation" msgstr "" +#. module: donation +#: field:donation.donation,message_is_follower:0 +msgid "Is a Follower" +msgstr "" + #. module: donation #: model:ir.model,name:donation.model_account_journal msgid "Journal" msgstr "" +#. module: donation +#: field:donation.donation,message_last_post:0 +msgid "Last Message Date" +msgstr "" + +#. module: donation +#: field:donation.campaign,write_uid:0 +#: field:donation.donation,write_uid:0 +#: field:donation.line,write_uid:0 +#: field:donation.validate,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: donation +#: field:donation.campaign,write_date:0 +#: field:donation.donation,write_date:0 +#: field:donation.line,write_date:0 +#: field:donation.validate,write_date:0 +msgid "Last Updated on" +msgstr "" + #. module: donation #: model:ir.module.category,description:donation.module_category_donation msgid "Manage donations" @@ -259,6 +361,28 @@ msgstr "" msgid "Manager" msgstr "" +#. module: donation +#: field:donation.donation,message_ids:0 +msgid "Messages" +msgstr "" + +#. module: donation +#: help:donation.donation,message_ids:0 +msgid "Messages and communication history" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:173 +#, python-format +msgid "Missing Default Debit Account on journal '%s'." +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:200 +#, python-format +msgid "Missing income account on product '%s' or on it's related product category" +msgstr "" + #. module: donation #: field:donation.campaign,name:0 msgid "Name" @@ -270,27 +394,45 @@ msgid "Notes" msgstr "" #. module: donation -#: view:donation.donation:0 -#: view:donation.report:0 +#: view:donation.donation:donation.donation_form +msgid "Other Information" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search #: model:ir.model,name:donation.model_res_partner msgid "Partner" msgstr "" #. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search +#: field:donation.report,country_id:0 +msgid "Partner Country" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_search #: field:donation.donation,journal_id:0 msgid "Payment Method" msgstr "" +#. module: donation +#: field:donation.donation,payment_ref:0 +msgid "Payment Reference" +msgstr "" + #. module: donation #: field:donation.line,product_id:0 -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_search #: field:donation.report,product_id:0 #: model:ir.model,name:donation.model_product_product msgid "Product" msgstr "" #. module: donation -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_search msgid "Product Category" msgstr "" @@ -311,7 +453,12 @@ msgid "Quantity" msgstr "" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_form +msgid "Save Default Values" +msgstr "" + +#. module: donation +#: view:donation.donation:donation.donation_search msgid "Search Donations" msgstr "" @@ -322,7 +469,7 @@ msgstr "" #. module: donation #: help:product.template,donation:0 -msgid "Specify if the product can be selectedin a donation line." +msgid "Specify if the product can be selected in a donation line." msgstr "" #. module: donation @@ -335,11 +482,55 @@ msgstr "" msgid "State" msgstr "" +#. module: donation +#: field:donation.donation,message_summary:0 +msgid "Summary" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:287 +#, python-format +msgid "The amount of the donation of %s (%s) is different from the sum of the donation lines (%s)." +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:160 +#, python-format +msgid "The date of the donation of %s should be today or in the past, not in the future!" +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:324 +#, python-format +msgid "The donation '%s' is in Done state, so you must set it back to draft before deleting it." +msgstr "" + +#. module: donation +#: code:addons/donation/donation.py:424 +#, python-format +msgid "The journal '%s' has the option 'Allow Donation', so it's type should be 'Cash' or 'Bank and Checks." +msgstr "" + +#. module: donation +#: model:product.template,description:donation.product_product_donation_product_template +msgid "This is a donation product." +msgstr "" + +#. module: donation +#: view:donation.validate:donation.donation_validate_form +msgid "This wizard will validate all the draft donations selected." +msgstr "" + #. module: donation #: field:donation.line,unit_price:0 msgid "Unit Price" msgstr "" +#. module: donation +#: field:donation.donation,message_unread:0 +msgid "Unread Messages" +msgstr "" + #. module: donation #: model:res.groups,name:donation.group_donation_user msgid "User" @@ -351,7 +542,18 @@ msgid "Users" msgstr "" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_form msgid "Validate" msgstr "" +#. module: donation +#: view:donation.validate:donation.donation_validate_form +#: model:ir.model,name:donation.model_donation_validate +msgid "Validate Donations" +msgstr "" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_validate_action +msgid "Validate Draft Donations" +msgstr "" + diff --git a/donation/i18n/fr.po b/donation/i18n/fr.po index cf23fc357..f4cf3d25b 100644 --- a/donation/i18n/fr.po +++ b/donation/i18n/fr.po @@ -1,30 +1,19 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: -# * donation +# * donation # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 8.0alpha1\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-07-01 13:43+0000\n" -"PO-Revision-Date: 2014-07-01 15:54+0100\n" +"POT-Creation-Date: 2015-02-17 22:41+0000\n" +"PO-Revision-Date: 2015-02-17 22:41+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" +"Content-Transfer-Encoding: \n" "Plural-Forms: \n" -"X-Generator: Poedit 1.5.7\n" - -#. module: donation -#: field:res.partner,donation_count:0 -msgid "# of Donations" -msgstr "# de dons" - -#. module: donation -#: field:res.partner,stay_count:0 -msgid "# of Stays" -msgstr "# de séjours" #. module: donation #: field:donation.donation,move_id:0 @@ -62,15 +51,32 @@ msgid "Analytic Account" msgstr "Compte analytique" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_form msgid "Back to Draft" msgstr "Retour à l'état brouillon" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_search msgid "Campaign" msgstr "Campagne de don" +#. module: donation +#: view:donation.validate:donation.donation_validate_form +msgid "Cancel" +msgstr "Cancel" + +#. module: donation +#: code:addons/donation/donation.py:274 +#, python-format +msgid "Cannot validate the donation of %s because it doesn't have any lines!" +msgstr "Cannot validate the donation of %s because it doesn't have any lines!" + +#. module: donation +#: code:addons/donation/donation.py:279 +#, python-format +msgid "Cannot validate the donation of %s because it is not in draft state." +msgstr "Cannot validate the donation of %s because it is not in draft state." + #. module: donation #: field:donation.report,product_categ_id:0 msgid "Category of Product" @@ -92,27 +98,40 @@ msgid "Code attributed for a Donation Campaign" msgstr "Code attribué pour une campagne de don" #. module: donation -#: field:donation.donation,company_id:0 view:donation.report:0 +#: field:donation.donation,company_id:0 +#: view:donation.report:donation.donation_report_search #: field:donation.report,company_id:0 msgid "Company" msgstr "Société" -#. module: donation -#: field:donation.donation,company_currency_id:0 -msgid "Company Currency" -msgstr "Monnaie de la Société" - #. module: donation #: model:ir.ui.menu,name:donation.donation_config_menu msgid "Configuration" msgstr "Configuration" #. module: donation +#: field:donation.donation,country_id:0 +msgid "Country" +msgstr "Country" + +#. module: donation +#: field:donation.campaign,create_uid:0 #: field:donation.donation,create_uid:0 +#: field:donation.line,create_uid:0 +#: field:donation.validate,create_uid:0 msgid "Created by" msgstr "Créé par" #. module: donation +#: field:donation.campaign,create_date:0 +#: field:donation.donation,create_date:0 +#: field:donation.line,create_date:0 +#: field:donation.validate,create_date:0 +msgid "Created on" +msgstr "Created on" + +#. module: donation +#: view:donation.donation:donation.donation_search #: field:donation.donation,currency_id:0 msgid "Currency" msgstr "Devise" @@ -123,30 +142,46 @@ msgid "Current Donation Campaign" msgstr "Campagne de don courante" #. module: donation -#: view:donation.donation:0 view:donation.report:0 +#: field:res.users,context_donation_journal_id:0 +msgid "Current Donation Payment Method" +msgstr "Current Donation Payment Method" + +#. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search msgid "Date" msgstr "Date" #. module: donation -#: constraint:donation.donation:0 -msgid "Date must be today or in the past" -msgstr "La date doit être du jour ou passée" +#: help:donation.donation,message_last_post:0 +msgid "Date of the last message posted on the record." +msgstr "Date of the last message posted on the record." #. module: donation -#: view:donation.donation:0 field:donation.line,donation_id:0 +#: field:donation.campaign,display_name:0 +msgid "Display Name" +msgstr "Display Name" + +#. module: donation +#: view:donation.donation:donation.donation_form +#: view:donation.donation:donation.donation_tree +#: field:donation.line,donation_id:0 #: model:ir.module.category,name:donation.module_category_donation -#: view:product.product:0 +#: view:product.template:donation.product_template_search_view +#: model:product.template,name:donation.product_product_donation_product_template msgid "Donation" msgstr "Don" #. module: donation -#: view:donation.campaign:0 field:donation.donation,campaign_id:0 -#: view:donation.report:0 field:donation.report,campaign_id:0 +#: view:donation.campaign:donation.donation_campaign_form +#: field:donation.donation,campaign_id:0 +#: view:donation.report:donation.donation_report_search +#: field:donation.report,campaign_id:0 msgid "Donation Campaign" msgstr "Campagne de don" #. module: donation -#: view:donation.campaign:0 +#: view:donation.campaign:donation.donation_campaign_tree #: model:ir.actions.act_window,name:donation.donation_campaign_action #: model:ir.ui.menu,name:donation.donation_campaign_menu msgid "Donation Campaigns" @@ -159,11 +194,13 @@ msgid "Donation Date" msgstr "Date du don" #. module: donation -#: view:donation.line:0 +#: view:donation.line:donation.donation_line_form +#: view:donation.line:donation.donation_line_tree msgid "Donation Line" msgstr "Ligne de don" #. module: donation +#: view:donation.donation:donation.donation_form #: field:donation.donation,line_ids:0 #: model:ir.model,name:donation.model_donation_line msgid "Donation Lines" @@ -175,20 +212,39 @@ msgid "Donation Number" msgstr "Numéro de don" #. module: donation -#: view:donation.donation:0 +#: field:account.journal,allow_donation:0 +msgid "Donation Payment Method" +msgstr "Donation Payment Method" + +#. module: donation +#: model:mail.message.subtype,description:donation.donation_done +#: model:mail.message.subtype,name:donation.donation_done +msgid "Donation Validated" +msgstr "Donation Validated" + +#. module: donation +#: code:addons/donation/donation.py:166 +#, python-format +msgid "Donation of %s" +msgstr "Donation of %s" + +#. module: donation +#: view:donation.donation:donation.donation_graph #: model:ir.actions.act_window,name:donation.donation_action #: model:ir.actions.act_window,name:donation.partner_donation_action #: model:ir.model,name:donation.model_donation_donation #: model:ir.ui.menu,name:donation.donation_menu #: model:ir.ui.menu,name:donation.donation_report_title_menu #: model:ir.ui.menu,name:donation.donation_title_menu -#: model:ir.ui.menu,name:donation.donation_top_menu view:res.partner:0 +#: model:ir.ui.menu,name:donation.donation_top_menu +#: view:res.partner:donation.view_partner_form #: field:res.partner,donation_ids:0 msgid "Donations" msgstr "Dons" #. module: donation -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_graph +#: view:donation.report:donation.donation_report_search #: model:ir.actions.act_window,name:donation.donation_report_action #: model:ir.model,name:donation.model_donation_report #: model:ir.ui.menu,name:donation.donation_report_menu @@ -201,12 +257,14 @@ msgid "Donations Lines" msgstr "Lignes de dons" #. module: donation -#: view:donation.donation:0 selection:donation.donation,state:0 +#: view:donation.donation:donation.donation_search +#: selection:donation.donation,state:0 msgid "Done" msgstr "Validé" #. module: donation -#: field:donation.donation,partner_id:0 field:donation.report,partner_id:0 +#: field:donation.donation,partner_id:0 +#: field:donation.report,partner_id:0 msgid "Donor" msgstr "Donateur" @@ -216,30 +274,83 @@ msgid "Donors" msgstr "Donateurs" #. module: donation -#: model:product.category,name:donation.product_category_donation -msgid "Dons" -msgstr "Dons" - -#. module: donation -#: view:donation.donation:0 selection:donation.donation,state:0 +#: view:donation.donation:donation.donation_search +#: selection:donation.donation,state:0 msgid "Draft" msgstr "Brouillon" #. module: donation -#: view:donation.donation:0 view:donation.report:0 +#: code:addons/donation/donation.py:333 +#, python-format +msgid "Draft Donation of %s" +msgstr "Draft Donation of %s" + +#. module: donation +#: field:donation.donation,message_follower_ids:0 +msgid "Followers" +msgstr "Followers" + +#. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search msgid "Group By" msgstr "Grouper par" +#. module: donation +#: help:donation.donation,message_summary:0 +msgid "Holds the Chatter summary (number of messages, ...). This summary is directly in html format in order to be inserted in kanban views." +msgstr "Holds the Chatter summary (number of messages, ...). This summary is directly in html format in order to be inserted in kanban views." + +#. module: donation +#: field:donation.campaign,id:0 +#: field:donation.donation,id:0 +#: field:donation.line,id:0 +#: field:donation.report,id:0 +#: field:donation.validate,id:0 +msgid "ID" +msgstr "ID" + +#. module: donation +#: help:donation.donation,message_unread:0 +msgid "If checked new messages require your attention." +msgstr "If checked new messages require your attention." + #. module: donation #: field:product.template,donation:0 msgid "Is a Donation" msgstr "Don" +#. module: donation +#: field:donation.donation,message_is_follower:0 +msgid "Is a Follower" +msgstr "Is a Follower" + #. module: donation #: model:ir.model,name:donation.model_account_journal msgid "Journal" msgstr "Journal" +#. module: donation +#: field:donation.donation,message_last_post:0 +msgid "Last Message Date" +msgstr "Last Message Date" + +#. module: donation +#: field:donation.campaign,write_uid:0 +#: field:donation.donation,write_uid:0 +#: field:donation.line,write_uid:0 +#: field:donation.validate,write_uid:0 +msgid "Last Updated by" +msgstr "Last Updated by" + +#. module: donation +#: field:donation.campaign,write_date:0 +#: field:donation.donation,write_date:0 +#: field:donation.line,write_date:0 +#: field:donation.validate,write_date:0 +msgid "Last Updated on" +msgstr "Last Updated on" + #. module: donation #: model:ir.module.category,description:donation.module_category_donation msgid "Manage donations" @@ -250,6 +361,28 @@ msgstr "Gérer les dons" msgid "Manager" msgstr "Responsable" +#. module: donation +#: field:donation.donation,message_ids:0 +msgid "Messages" +msgstr "Messages" + +#. module: donation +#: help:donation.donation,message_ids:0 +msgid "Messages and communication history" +msgstr "Messages and communication history" + +#. module: donation +#: code:addons/donation/donation.py:173 +#, python-format +msgid "Missing Default Debit Account on journal '%s'." +msgstr "Missing Default Debit Account on journal '%s'." + +#. module: donation +#: code:addons/donation/donation.py:200 +#, python-format +msgid "Missing income account on product '%s' or on it's related product category" +msgstr "Missing income account on product '%s' or on it's related product category" + #. module: donation #: field:donation.campaign,name:0 msgid "Name" @@ -261,32 +394,52 @@ msgid "Notes" msgstr "Notes" #. module: donation -#: view:donation.donation:0 view:donation.report:0 +#: view:donation.donation:donation.donation_form +msgid "Other Information" +msgstr "Other Information" + +#. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search #: model:ir.model,name:donation.model_res_partner msgid "Partner" msgstr "Partenaire" #. module: donation +#: view:donation.donation:donation.donation_search +#: view:donation.report:donation.donation_report_search +#: field:donation.report,country_id:0 +msgid "Partner Country" +msgstr "Partner Country" + +#. module: donation +#: view:donation.donation:donation.donation_search #: field:donation.donation,journal_id:0 msgid "Payment Method" msgstr "Méthode de paiement" #. module: donation -#: field:donation.line,product_id:0 view:donation.report:0 +#: field:donation.donation,payment_ref:0 +msgid "Payment Reference" +msgstr "Payment Reference" + +#. module: donation +#: field:donation.line,product_id:0 +#: view:donation.report:donation.donation_report_search #: field:donation.report,product_id:0 #: model:ir.model,name:donation.model_product_product msgid "Product" msgstr "Produit" #. module: donation -#: view:donation.report:0 +#: view:donation.report:donation.donation_report_search msgid "Product Category" msgstr "Catégorie de produit" #. module: donation #: model:ir.model,name:donation.model_product_template msgid "Product Template" -msgstr "Modèle d'article" +msgstr "Product Template" #. module: donation #: model:ir.actions.act_window,name:donation.donation_product_action @@ -300,7 +453,12 @@ msgid "Quantity" msgstr "Quantité" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_form +msgid "Save Default Values" +msgstr "Save Default Values" + +#. module: donation +#: view:donation.donation:donation.donation_search msgid "Search Donations" msgstr "Recherche des dons" @@ -324,11 +482,55 @@ msgstr "Date de départ" msgid "State" msgstr "État" +#. module: donation +#: field:donation.donation,message_summary:0 +msgid "Summary" +msgstr "Summary" + +#. module: donation +#: code:addons/donation/donation.py:287 +#, python-format +msgid "The amount of the donation of %s (%s) is different from the sum of the donation lines (%s)." +msgstr "The amount of the donation of %s (%s) is different from the sum of the donation lines (%s)." + +#. module: donation +#: code:addons/donation/donation.py:160 +#, python-format +msgid "The date of the donation of %s should be today or in the past, not in the future!" +msgstr "The date of the donation of %s should be today or in the past, not in the future!" + +#. module: donation +#: code:addons/donation/donation.py:324 +#, python-format +msgid "The donation '%s' is in Done state, so you must set it back to draft before deleting it." +msgstr "The donation '%s' is in Done state, so you must set it back to draft before deleting it." + +#. module: donation +#: code:addons/donation/donation.py:424 +#, python-format +msgid "The journal '%s' has the option 'Allow Donation', so it's type should be 'Cash' or 'Bank and Checks." +msgstr "The journal '%s' has the option 'Allow Donation', so it's type should be 'Cash' or 'Bank and Checks." + +#. module: donation +#: model:product.template,description:donation.product_product_donation_product_template +msgid "This is a donation product." +msgstr "This is a donation product." + +#. module: donation +#: view:donation.validate:donation.donation_validate_form +msgid "This wizard will validate all the draft donations selected." +msgstr "This wizard will validate all the draft donations selected." + #. module: donation #: field:donation.line,unit_price:0 msgid "Unit Price" msgstr "Prix unitaire" +#. module: donation +#: field:donation.donation,message_unread:0 +msgid "Unread Messages" +msgstr "Unread Messages" + #. module: donation #: model:res.groups,name:donation.group_donation_user msgid "User" @@ -340,6 +542,18 @@ msgid "Users" msgstr "Utilisateurs" #. module: donation -#: view:donation.donation:0 +#: view:donation.donation:donation.donation_form msgid "Validate" msgstr "Valider" + +#. module: donation +#: view:donation.validate:donation.donation_validate_form +#: model:ir.model,name:donation.model_donation_validate +msgid "Validate Donations" +msgstr "Validate Donations" + +#. module: donation +#: model:ir.actions.act_window,name:donation.donation_validate_action +msgid "Validate Draft Donations" +msgstr "Validate Draft Donations" + From 07a2b518d23da9bccc0bfae00f14f1cf57bddabd Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 18 Feb 2015 14:19:54 +0100 Subject: [PATCH 057/172] donation/report : Port to new API --- donation/report/donation_report.py | 37 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/donation/report/donation_report.py b/donation/report/donation_report.py index 15b16541a..cfc697e1b 100644 --- a/donation/report/donation_report.py +++ b/donation/report/donation_report.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Barroux Abbey +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey +# @author: Alexis de Lattre # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,31 +21,29 @@ ############################################################################## from openerp import tools -from openerp.osv import orm, fields +from openerp import models, fields -class donation_report(orm.Model): +class DonationReport(models.Model): _name = "donation.report" _description = "Donations Analysis" _auto = False _rec_name = 'donation_date' _order = "donation_date desc" - _columns = { - 'donation_date': fields.date('Donation Date', readonly=True), - 'product_id': fields.many2one( - 'product.product', 'Product', readonly=True), - 'partner_id': fields.many2one('res.partner', 'Donor', readonly=True), - 'country_id': fields.many2one( - 'res.country', 'Partner Country', readonly=True), - 'company_id': fields.many2one('res.company', 'Company', readonly=True), - 'product_categ_id': fields.many2one( - 'product.category', 'Category of Product', readonly=True), - 'campaign_id': fields.many2one( - 'donation.campaign', 'Donation Campaign', readonly=True), - 'amount_company_currency': fields.float( - 'Amount Company Currency', readonly=True), - } + donation_date = fields.Date(string='Donation Date', readonly=True) + product_id = fields.Many2one( + 'product.product', string='Product', readonly=True) + partner_id = fields.Many2one('res.partner', string='Donor', readonly=True) + country_id = fields.Many2one( + 'res.country', string='Partner Country', readonly=True) + company_id = fields.Many2one('res.company', string='Company', readonly=True) + product_categ_id = fields.Many2one( + 'product.category', string='Category of Product', readonly=True) + campaign_id = fields.Many2one( + 'donation.campaign', string='Donation Campaign', readonly=True) + amount_company_currency = fields.Float( + 'Amount Company Currency', readonly=True) def _select(self): select = """ From 741c75d78b49971b81774e9940ecc5969fdf04cd Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 18 Feb 2015 21:38:01 +0100 Subject: [PATCH 058/172] Add support for in-kind donations Add in-kind and tax-receipt options in donation report Add copyright notice in some XML files --- donation/__openerp__.py | 2 +- donation/donation.py | 23 +++++++--- donation/donation_campaign_view.xml | 5 +-- donation/donation_demo.xml | 57 ++++++++++++++++++++++++ donation/donation_view.xml | 7 +++ donation/i18n/donation.pot | 37 +++++++++++---- donation/i18n/fr.po | 37 +++++++++++---- donation/product.py | 13 ++++++ donation/product_view.xml | 9 ++++ donation/report/donation_report.py | 3 ++ donation/report/donation_report_view.xml | 8 ++++ donation/test/validate.yml | 26 +++++++++++ donation/users_view.xml | 5 +++ 13 files changed, 205 insertions(+), 27 deletions(-) diff --git a/donation/__openerp__.py b/donation/__openerp__.py index e7d47fcc1..4cf6c5b6b 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -30,7 +30,7 @@ Donation ======== -This module handles donations. +This module handles donations, including in-kind donations. It has been developped by brother Bernard and brother Irenee from Barroux Abbey and by Alexis de Lattre from Akretion. """, diff --git a/donation/donation.py b/donation/donation.py index 0dca3e526..5f4131919 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -190,6 +190,8 @@ def _prepare_donation_move(self): # key = (account_id, analytic_account_id) # value = {'credit': ..., 'debit': ..., 'amount_currency': ...} for donation_line in self.line_ids: + if donation_line.in_kind: + continue amount_total_company_cur += donation_line.amount_company_currency account_id = donation_line.product_id.property_account_income.id if not account_id: @@ -224,6 +226,9 @@ def _prepare_donation_move(self): 'amount_currency': amount_currency, } + if not aml: # for full in-kind donation + return False + for (account_id, analytic_account_id), content in aml.iteritems(): movelines.append((0, 0, { 'name': name, @@ -293,9 +298,14 @@ def validate(self): if self.amount_total: move_vals = self._prepare_donation_move() - move = self.env['account.move'].create(move_vals) - move.post() - donation_write_vals['move_id'] = move.id + # when we have a full in-kind donation: no account move + if move_vals: + move = self.env['account.move'].create(move_vals) + move.post() + donation_write_vals['move_id'] = move.id + else: + self.message_post( + _('Full in-kind donation: no account move generated')) self.write(donation_write_vals) return @@ -381,12 +391,15 @@ def _compute_amount_company_currency(self): analytic_account_id = fields.Many2one( 'account.analytic.account', string='Analytic Account', domain=[('type', 'not in', ('view', 'template'))], ondelete='restrict') + in_kind = fields.Boolean(string='In Kind') sequence = fields.Integer('Sequence') @api.onchange('product_id') def product_id_change(self): - if self.product_id and self.product_id.list_price: - self.unit_price = self.product_id.list_price + if self.product_id: + if self.product_id.list_price: + self.unit_price = self.product_id.list_price + self.in_kind = self.product_id.in_kind_donation @api.model def get_analytic_account_id(self): diff --git a/donation/donation_campaign_view.xml b/donation/donation_campaign_view.xml index cec492a82..9f6f3992f 100644 --- a/donation/donation_campaign_view.xml +++ b/donation/donation_campaign_view.xml @@ -1,8 +1,7 @@ - diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index 86c9f26c6..ccd659f84 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -17,6 +17,19 @@ This is a donation product. + + In-Kind Donation + KIND-DON + + + 1 + 1 + 0 + service + + + + @@ -119,6 +132,50 @@ 150 + + + + 1000 + + + + + + + + + + + 1 + 1000 + + + + + + + 1200 + + + + + + + + + + + 1 + 800 + + + + + + + 1 + 400 + diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 2d485cee9..c8f6570be 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -1,4 +1,9 @@ + @@ -134,6 +139,7 @@ + @@ -152,6 +158,7 @@ +
diff --git a/donation/i18n/donation.pot b/donation/i18n/donation.pot index 23c550fbc..fefc2e698 100644 --- a/donation/i18n/donation.pot +++ b/donation/i18n/donation.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-02-17 22:34+0000\n" -"PO-Revision-Date: 2015-02-17 22:34+0000\n" +"POT-Creation-Date: 2015-02-18 20:36+0000\n" +"PO-Revision-Date: 2015-02-18 20:36+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -66,13 +66,13 @@ msgid "Cancel" msgstr "" #. module: donation -#: code:addons/donation/donation.py:274 +#: code:addons/donation/donation.py:279 #, python-format msgid "Cannot validate the donation of %s because it doesn't have any lines!" msgstr "" #. module: donation -#: code:addons/donation/donation.py:279 +#: code:addons/donation/donation.py:284 #, python-format msgid "Cannot validate the donation of %s because it is not in draft state." msgstr "" @@ -280,7 +280,7 @@ msgid "Draft" msgstr "" #. module: donation -#: code:addons/donation/donation.py:333 +#: code:addons/donation/donation.py:343 #, python-format msgid "Draft Donation of %s" msgstr "" @@ -290,6 +290,12 @@ msgstr "" msgid "Followers" msgstr "" +#. module: donation +#: code:addons/donation/donation.py:308 +#, python-format +msgid "Full in-kind donation: no account move generated" +msgstr "" + #. module: donation #: view:donation.donation:donation.donation_search #: view:donation.report:donation.donation_report_search @@ -315,6 +321,19 @@ msgstr "" msgid "If checked new messages require your attention." msgstr "" +#. module: donation +#: field:donation.line,in_kind:0 +#: view:donation.report:donation.donation_report_search +#: field:donation.report,in_kind:0 +msgid "In Kind" +msgstr "" + +#. module: donation +#: field:product.template,in_kind_donation:0 +#: model:product.template,name:donation.product_product_inkind_donation_product_template +msgid "In-Kind Donation" +msgstr "" + #. module: donation #: field:product.template,donation:0 msgid "Is a Donation" @@ -378,7 +397,7 @@ msgid "Missing Default Debit Account on journal '%s'." msgstr "" #. module: donation -#: code:addons/donation/donation.py:200 +#: code:addons/donation/donation.py:202 #, python-format msgid "Missing income account on product '%s' or on it's related product category" msgstr "" @@ -488,7 +507,7 @@ msgid "Summary" msgstr "" #. module: donation -#: code:addons/donation/donation.py:287 +#: code:addons/donation/donation.py:292 #, python-format msgid "The amount of the donation of %s (%s) is different from the sum of the donation lines (%s)." msgstr "" @@ -500,13 +519,13 @@ msgid "The date of the donation of %s should be today or in the past, not in the msgstr "" #. module: donation -#: code:addons/donation/donation.py:324 +#: code:addons/donation/donation.py:334 #, python-format msgid "The donation '%s' is in Done state, so you must set it back to draft before deleting it." msgstr "" #. module: donation -#: code:addons/donation/donation.py:424 +#: code:addons/donation/donation.py:437 #, python-format msgid "The journal '%s' has the option 'Allow Donation', so it's type should be 'Cash' or 'Bank and Checks." msgstr "" diff --git a/donation/i18n/fr.po b/donation/i18n/fr.po index f4cf3d25b..5a6f7aea1 100644 --- a/donation/i18n/fr.po +++ b/donation/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-02-17 22:41+0000\n" -"PO-Revision-Date: 2015-02-17 22:41+0000\n" +"POT-Creation-Date: 2015-02-18 20:37+0000\n" +"PO-Revision-Date: 2015-02-18 20:37+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -66,13 +66,13 @@ msgid "Cancel" msgstr "Cancel" #. module: donation -#: code:addons/donation/donation.py:274 +#: code:addons/donation/donation.py:279 #, python-format msgid "Cannot validate the donation of %s because it doesn't have any lines!" msgstr "Cannot validate the donation of %s because it doesn't have any lines!" #. module: donation -#: code:addons/donation/donation.py:279 +#: code:addons/donation/donation.py:284 #, python-format msgid "Cannot validate the donation of %s because it is not in draft state." msgstr "Cannot validate the donation of %s because it is not in draft state." @@ -280,7 +280,7 @@ msgid "Draft" msgstr "Brouillon" #. module: donation -#: code:addons/donation/donation.py:333 +#: code:addons/donation/donation.py:343 #, python-format msgid "Draft Donation of %s" msgstr "Draft Donation of %s" @@ -290,6 +290,12 @@ msgstr "Draft Donation of %s" msgid "Followers" msgstr "Followers" +#. module: donation +#: code:addons/donation/donation.py:308 +#, python-format +msgid "Full in-kind donation: no account move generated" +msgstr "Full in-kind donation: no account move generated" + #. module: donation #: view:donation.donation:donation.donation_search #: view:donation.report:donation.donation_report_search @@ -315,6 +321,19 @@ msgstr "ID" msgid "If checked new messages require your attention." msgstr "If checked new messages require your attention." +#. module: donation +#: field:donation.line,in_kind:0 +#: view:donation.report:donation.donation_report_search +#: field:donation.report,in_kind:0 +msgid "In Kind" +msgstr "En nature" + +#. module: donation +#: field:product.template,in_kind_donation:0 +#: model:product.template,name:donation.product_product_inkind_donation_product_template +msgid "In-Kind Donation" +msgstr "Don en nature" + #. module: donation #: field:product.template,donation:0 msgid "Is a Donation" @@ -378,7 +397,7 @@ msgid "Missing Default Debit Account on journal '%s'." msgstr "Missing Default Debit Account on journal '%s'." #. module: donation -#: code:addons/donation/donation.py:200 +#: code:addons/donation/donation.py:202 #, python-format msgid "Missing income account on product '%s' or on it's related product category" msgstr "Missing income account on product '%s' or on it's related product category" @@ -488,7 +507,7 @@ msgid "Summary" msgstr "Summary" #. module: donation -#: code:addons/donation/donation.py:287 +#: code:addons/donation/donation.py:292 #, python-format msgid "The amount of the donation of %s (%s) is different from the sum of the donation lines (%s)." msgstr "The amount of the donation of %s (%s) is different from the sum of the donation lines (%s)." @@ -500,13 +519,13 @@ msgid "The date of the donation of %s should be today or in the past, not in the msgstr "The date of the donation of %s should be today or in the past, not in the future!" #. module: donation -#: code:addons/donation/donation.py:324 +#: code:addons/donation/donation.py:334 #, python-format msgid "The donation '%s' is in Done state, so you must set it back to draft before deleting it." msgstr "The donation '%s' is in Done state, so you must set it back to draft before deleting it." #. module: donation -#: code:addons/donation/donation.py:424 +#: code:addons/donation/donation.py:437 #, python-format msgid "The journal '%s' has the option 'Allow Donation', so it's type should be 'Cash' or 'Bank and Checks." msgstr "The journal '%s' has the option 'Allow Donation', so it's type should be 'Cash' or 'Bank and Checks." diff --git a/donation/product.py b/donation/product.py index 4e0fcc714..e2ba5899f 100644 --- a/donation/product.py +++ b/donation/product.py @@ -29,6 +29,8 @@ class ProductTemplate(models.Model): string='Is a Donation', help="Specify if the product can be selected " "in a donation line.") + in_kind_donation = fields.Boolean( + string="In-Kind Donation") @api.onchange('donation') def _donation_change(self): @@ -36,6 +38,10 @@ def _donation_change(self): self.type = 'service' self.sale_ok = False + @api.onchange('in_kind_donation') + def _in_kind_donation_change(self): + if self.in_kind_donation: + self.donation = True class ProductProduct(models.Model): _inherit = 'product.product' @@ -45,3 +51,10 @@ def _donation_change(self): if self.donation: self.type = 'service' self.sale_ok = False + + @api.onchange('in_kind_donation') + def _in_kind_donation_change(self): + if self.in_kind_donation: + self.donation = True + + diff --git a/donation/product_view.xml b/donation/product_view.xml index 57c1bdcc1..8093e8eeb 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -1,4 +1,9 @@ + @@ -24,6 +29,10 @@
+
+ +
diff --git a/donation/report/donation_report.py b/donation/report/donation_report.py index cfc697e1b..8abedb2b7 100644 --- a/donation/report/donation_report.py +++ b/donation/report/donation_report.py @@ -42,6 +42,7 @@ class DonationReport(models.Model): 'product.category', string='Category of Product', readonly=True) campaign_id = fields.Many2one( 'donation.campaign', string='Donation Campaign', readonly=True) + in_kind = fields.Boolean(string='In Kind') amount_company_currency = fields.Float( 'Amount Company Currency', readonly=True) @@ -50,6 +51,7 @@ def _select(self): SELECT min(l.id) AS id, d.donation_date AS donation_date, l.product_id AS product_id, + l.in_kind AS in_kind, pt.categ_id AS product_categ_id, d.company_id AS company_id, d.partner_id AS partner_id, @@ -77,6 +79,7 @@ def _where(self): def _group_by(self): group_by = """ GROUP BY l.product_id, + l.in_kind, pt.categ_id, d.donation_date, d.partner_id, diff --git a/donation/report/donation_report_view.xml b/donation/report/donation_report_view.xml index de16807b6..590526b16 100644 --- a/donation/report/donation_report_view.xml +++ b/donation/report/donation_report_view.xml @@ -1,4 +1,9 @@ + @@ -14,6 +19,7 @@ +
@@ -27,6 +33,8 @@ donation.report + + diff --git a/donation/test/validate.yml b/donation/test/validate.yml index 0f7e3ff18..e6f2fd71a 100644 --- a/donation/test/validate.yml +++ b/donation/test/validate.yml @@ -38,3 +38,29 @@ - move_id.date == time.strftime('%Y-%m-01') - move_id.journal_id.id == ref('account.cash_journal') - move_id.state == 'posted' +- + Validate donation4 +- + !function {model: donation.donation, name: validate}: + - eval: "[obj(ref('donation4')).id]" +- + Donation4 Check that no account move has been generated (full in-kind donation) +- + !python {model: donation.donation}: | + donation = self.browse(cr, uid, ref('donation4'), context=context) + assert donation.state == 'done', 'Donation has not been set to done (donation4)' + assert not donation.move_id, 'Donation should not have an account move (donation4)' +- + Validate donation5 +- + !function {model: donation.donation, name: validate}: + - eval: "[obj(ref('donation5')).id]" +- + Donation5 Check that an account move has been generated (partial in-kind donation) +- + !python {model: donation.donation}: | + donation = self.browse(cr, uid, ref('donation5'), context=context) + assert donation.state == 'done', 'Donation has not been set to done (donation5)' + assert donation.move_id, 'No account move generated (donation5)' + # How to make this check work when the company currency != EUR ? + assert donation.move_id.amount == 400, 'Wrong amount on account move' diff --git a/donation/users_view.xml b/donation/users_view.xml index 353fd471f..d694535c9 100644 --- a/donation/users_view.xml +++ b/donation/users_view.xml @@ -1,4 +1,9 @@ + From ac87cbff3789c8ea6865d58636857593041973de Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 20 Feb 2015 17:07:18 +0100 Subject: [PATCH 059/172] Fix R/W access on user preferences --- donation/users_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/donation/users_view.xml b/donation/users_view.xml index d694535c9..e1867bc5b 100644 --- a/donation/users_view.xml +++ b/donation/users_view.xml @@ -27,9 +27,9 @@ + groups="donation.group_donation_user" readonly="0"/> + groups="donation.group_donation_user" readonly="0"/> From bf470146a574a2ea8f8e8151b7c41426cdb621a9 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 28 Mar 2015 01:55:10 +0100 Subject: [PATCH 060/172] Prepare move to OCA : flake8, add OCA as author, add README.rst, update Copyright --- donation/README.rst | 43 ++++++++++++++++++++++ donation/__init__.py | 5 ++- donation/__openerp__.py | 15 ++------ donation/donation.py | 7 ++-- donation/donation_campaign.py | 7 ++-- donation/donation_campaign_view.xml | 1 + donation/donation_view.xml | 1 + donation/partner_view.xml | 4 +- donation/product.py | 8 ++-- donation/product_view.xml | 1 + donation/report/__init__.py | 5 ++- donation/report/donation_report.py | 6 ++- donation/report/donation_report_view.xml | 1 + donation/security/donation_security.xml | 4 +- donation/users_view.xml | 1 + donation/wizard/__init__.py | 3 +- donation/wizard/donation_validate.py | 3 +- donation/wizard/donation_validate_view.xml | 4 +- 18 files changed, 84 insertions(+), 35 deletions(-) create mode 100644 donation/README.rst diff --git a/donation/README.rst b/donation/README.rst new file mode 100644 index 000000000..9a1386f2c --- /dev/null +++ b/donation/README.rst @@ -0,0 +1,43 @@ +Donation +======== + +This module handles donations, including in-kind donations. When you validate a donation, it will create the corresponding accounting entries. + +Configuration +============= + +To configure this module, you need to: + + * create donation products + * activate the option *Donation Payment Method* on some bank/cash account journals + * if you wish to have a control amount on the donation, add the users to the group *Check Total on supplier invoices* + +Usage +===== + +To use this module, go to the menu Donations > Donations and start to register new donations. + +To have some statistics about the donations, go to the menu Reporting > Donations > Donations Analysis. + +Credits +======= + +Contributors +------------ + +* Brother Bernard +* Brother Irénée (Barroux Abbey) +* Alexis de Lattre + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/donation/__init__.py b/donation/__init__.py index 27727c046..1612c9022 100644 --- a/donation/__init__.py +++ b/donation/__init__.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Barroux Abbey +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/donation/__openerp__.py b/donation/__openerp__.py index 4cf6c5b6b..524a6209d 100644 --- a/donation/__openerp__.py +++ b/donation/__openerp__.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Abbaye du Barroux +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -26,15 +27,7 @@ 'category': 'Accounting & Finance', 'license': 'AGPL-3', 'summary': 'Manage donations', - 'description': """ -Donation -======== - -This module handles donations, including in-kind donations. - -It has been developped by brother Bernard and brother Irenee from Barroux Abbey and by Alexis de Lattre from Akretion. - """, - 'author': 'Barroux, Akretion', + 'author': 'Barroux Abbey, Akretion, Odoo Community Association (OCA)', 'website': 'http://www.barroux.org', 'depends': ['account_accountant'], 'data': [ diff --git a/donation/donation.py b/donation/donation.py index 5f4131919..4d183c246 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Barroux Abbey +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -40,7 +41,7 @@ class ResUsers(models.Model): class DonationDonation(models.Model): _name = 'donation.donation' - _description = 'Donations' + _description = 'Donation' _order = 'id desc' _rec_name = 'display_name' _inherit = ['mail.thread'] diff --git a/donation/donation_campaign.py b/donation/donation_campaign.py index 17579f896..5904e2a64 100644 --- a/donation/donation_campaign.py +++ b/donation/donation_campaign.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Barroux Abbey +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +23,7 @@ from openerp import models, fields, api -class donation_campaign(models.Model): +class DonationCampaign(models.Model): _name = 'donation.campaign' _description = 'Code attributed for a Donation Campaign' _order = 'code' diff --git a/donation/donation_campaign_view.xml b/donation/donation_campaign_view.xml index 9f6f3992f..3584c4f06 100644 --- a/donation/donation_campaign_view.xml +++ b/donation/donation_campaign_view.xml @@ -1,6 +1,7 @@ diff --git a/donation/donation_view.xml b/donation/donation_view.xml index c8f6570be..2ca41e143 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -1,6 +1,7 @@ diff --git a/donation/partner_view.xml b/donation/partner_view.xml index bedaef491..2cc66e1d9 100644 --- a/donation/partner_view.xml +++ b/donation/partner_view.xml @@ -1,8 +1,8 @@ diff --git a/donation/product.py b/donation/product.py index e2ba5899f..cbb683e22 100644 --- a/donation/product.py +++ b/donation/product.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Barroux Abbey +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -43,6 +44,7 @@ def _in_kind_donation_change(self): if self.in_kind_donation: self.donation = True + class ProductProduct(models.Model): _inherit = 'product.product' @@ -56,5 +58,3 @@ def _donation_change(self): def _in_kind_donation_change(self): if self.in_kind_donation: self.donation = True - - diff --git a/donation/product_view.xml b/donation/product_view.xml index 8093e8eeb..ed83ee83d 100644 --- a/donation/product_view.xml +++ b/donation/product_view.xml @@ -1,6 +1,7 @@ diff --git a/donation/report/__init__.py b/donation/report/__init__.py index 012507d69..00e9d52f8 100644 --- a/donation/report/__init__.py +++ b/donation/report/__init__.py @@ -1,8 +1,9 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Donation module for OpenERP -# Copyright (C) 2014 Barroux Abbey +# Donation module for Odoo +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/donation/report/donation_report.py b/donation/report/donation_report.py index 8abedb2b7..be3a3d7d2 100644 --- a/donation/report/donation_report.py +++ b/donation/report/donation_report.py @@ -2,7 +2,8 @@ ############################################################################## # # Donation module for Odoo -# Copyright (C) 2014-2015 Barroux Abbey +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # @author: Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -37,7 +38,8 @@ class DonationReport(models.Model): partner_id = fields.Many2one('res.partner', string='Donor', readonly=True) country_id = fields.Many2one( 'res.country', string='Partner Country', readonly=True) - company_id = fields.Many2one('res.company', string='Company', readonly=True) + company_id = fields.Many2one( + 'res.company', string='Company', readonly=True) product_categ_id = fields.Many2one( 'product.category', string='Category of Product', readonly=True) campaign_id = fields.Many2one( diff --git a/donation/report/donation_report_view.xml b/donation/report/donation_report_view.xml index 590526b16..6a108d450 100644 --- a/donation/report/donation_report_view.xml +++ b/donation/report/donation_report_view.xml @@ -1,6 +1,7 @@ diff --git a/donation/security/donation_security.xml b/donation/security/donation_security.xml index cbb7f4663..1ec0235f7 100644 --- a/donation/security/donation_security.xml +++ b/donation/security/donation_security.xml @@ -1,8 +1,8 @@ diff --git a/donation/users_view.xml b/donation/users_view.xml index e1867bc5b..8b51e91b1 100644 --- a/donation/users_view.xml +++ b/donation/users_view.xml @@ -1,6 +1,7 @@ diff --git a/donation/wizard/__init__.py b/donation/wizard/__init__.py index 50f97fea0..e2346ad85 100644 --- a/donation/wizard/__init__.py +++ b/donation/wizard/__init__.py @@ -2,7 +2,8 @@ ############################################################################## # # Donation module for Odoo -# Copyright (C) 2014 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/donation/wizard/donation_validate.py b/donation/wizard/donation_validate.py index e31c2981d..fccacec35 100644 --- a/donation/wizard/donation_validate.py +++ b/donation/wizard/donation_validate.py @@ -2,7 +2,8 @@ ############################################################################## # # Donation module for Odoo -# Copyright (C) 2014 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Barroux Abbey (www.barroux.org) +# Copyright (C) 2014-2015 Akretion France (www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify diff --git a/donation/wizard/donation_validate_view.xml b/donation/wizard/donation_validate_view.xml index a7b513b50..2fb9006f8 100644 --- a/donation/wizard/donation_validate_view.xml +++ b/donation/wizard/donation_validate_view.xml @@ -1,8 +1,8 @@ From c167162cb1fc9c4604ccb86026e66527ae06eaa7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 30 Mar 2015 00:36:00 +0200 Subject: [PATCH 061/172] Write a real README.md for the project Fix flake8 warning --- donation/donation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/donation/donation.py b/donation/donation.py index 4d183c246..8b73b022b 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -28,6 +28,7 @@ class ResUsers(models.Model): _inherit = 'res.users' + # begin with context_ to allow user to change it by himself context_donation_campaign_id = fields.Many2one( 'donation.campaign', string='Current Donation Campaign') context_donation_journal_id = fields.Many2one( @@ -36,7 +37,6 @@ class ResUsers(models.Model): ('type', 'in', ('bank', 'cash')), ('allow_donation', '=', True)], company_dependent=True) - # begin with context_ to allow user to change it by itself class DonationDonation(models.Model): From e0a445ebe68c2c2785638d62605ff2f0986f8ffe Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 5 Apr 2015 16:34:57 +0200 Subject: [PATCH 062/172] Add icons --- donation/static/description/icon.png | Bin 0 -> 14015 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 donation/static/description/icon.png diff --git a/donation/static/description/icon.png b/donation/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f443e075f44b834719b2d55035f1acc07ff12fcf GIT binary patch literal 14015 zcma)jWm6m6^L7XUf(I*Jf?IKi0>RxWUZl7bhvEbXS{zzji@R%qKqyj5arZ)zqQxop zzkl<5foIO_**W`ecXrS2%(Yjnwx$w34iydn0KivKme>7H!~Z8>%>Qnbl-1aO3iF+s zl04w~f2XjgJncUVw!5;i7XW}u@;^ZXWam=+XTvfB4ht~tz@lih*0Ev=+ox?a8 z{M=sTwjwdvjSG|~(=@-#I5I3S1B-bF>*v7s_OU^I-|$tDGM03_I5dr?YPT=X95??( z4i5N^0C>>XU-o$z4gN$NbdJ??B6}nSO#NY05kr0Tx|op)U!4^k@@APTzta0LPb~7NvUgde+dV) z2oR}^HMs`1Yd0zmCMT?-Curbd(H=QTcDYxs!sKVNRA3QPv$F8fM(0fE02~?N9#SH zPdM^A&hJXMp>N6QnG?66v{>{YT~#k|*lbrqj8Rq{Tt%*892hVUBTX0e?s=Lm z@@J6U&Jb4EV^XHVl#{T8l>fCKw>*)J&(ZuFZhq0VdiD z{P~I{WT7-z2mZCsWPI+}xS~Yp#^s^!q#z})L>i!rI7bwG1T}hCfR%*IM2x8P%l#4iY_dZJ#h0%UkWJC3vy0I$EPz+w5{PoC$$!6sZgr)! zh~0cE0sFYW*#cz6lZqY$M!W7zo(6clOy**u3#=U#b%a6ryxbp0X3W^VUt;{lXn2E? zz66+-*jO&{e=VYCV8^D$wnE$w}wk zr^LQw*Q{w3vSHe)z>RWqZaq5MNX6~UK{v(#b#~J6QzM9=48vP;rI`8W7f0VZ;H1D| zAJgg{5}Wt1<^o6hNsV8oCp*ewtctr+SPgq?vrkXm?}Nhh&;aOE=ASS>qlst9v!=;g zDev5a^z`@4q3de3$O*a~S}B1~bF? z0PAKfG#v89{S7;Fdz zX(!Dl5q3a-JMYE|etn@2Kq^vtHAh{E%Tywo28VCPZG>XUSl5B_M8n&$aqMomFO$M< zx#(bKZVqvD!;VB2zGh#VUdZ&Wh0b-$_vz-cZzG<+aG zFf6ihmPq7VhVgTi?gI}=3J)4|anhZLdK{0GeCb8KPOoxt0Lj?~@~-CNd3P@h2oMEY z>0ql@nf^fii+!F0JsIp8XZ1{P^WPeW^Yq#Ebm&uq+t4SHzxSGe3W_bp-QqNzZsH0} z41hX^`X2*(Sq08?Cu2KmXkwb>FArj~*O~-VIQT0K9(z?uBo@XW+~fb0{+C994C?E- zyD3)sHEsZ0#21gS;bzr>m<`kviB1bfcwDi6Y&{>l_15YJtvDILoi1~=^B|F~YVi+! z+%A}I8^{U@w1Dr|qU>IA)@sxh>n1^ao8C1n|3vf6#{t}aY7mj`LJ|rUei;Gudq(&% zomT3DuNq@EutBBjCON+WI_f7GnPV^8wnfT;fVyGerhD}K%&7Rb8B7|3v-d(I?rx@U z*YvTg^B>neVOBMr!&At2AXM0O@o9he+z}hzgVeNQwXE45es8BsN+}6rpQNHyNXkCb zT6Q{x_9il<>mp1@ydiy~Ppl5VLGV$MN_QLp49$Yv087+8ovbul-q1-C#CBCO^5Mz> zOxL%bxoW5*?|@A=*a2_aEO033s0Xe@t#}WlK>#Q_f~f5ymHSGa={Gs z=I#7Pf(ua)GJIo3=irI?xX9VJr?)@*I_ZzYhT}Xv94+kaoel-Dr4!);!7r@L*|UKA z#}FbtjK>+hF!Wq|x={QeVARWXBp#N`2+&2>B?w;Ol_En4qADIG? z71rPFY70|W5gF4z6Q7XA1`J0MWPnY#=skRDfm@5PXj)E^QxnV5wnSbRjW&k>>^-!8 z+1(r|P2bR((~7b-x3DGM+ku8RT&w#~srjR|H7R34v<0+2!Uqe@l$uQ}xQJ=wS%xo$ zLu}>B$FU(%YFAHmT98*`I6>YfUyfUn;+Av3UH0Gt6_xA$V-<;|`|1|-m^8IT> zW-rDH?;BY|eCY(VGlzkGdiO)$+ZC%@wzG*$vyKgt%qQ-?=+T8Fa!X-caV8i9#t;@$ z-1*8p2T}BH%Q`rISm`P+^DC=CLaE3L}oO_Z4l(e6?QO zAIKa0Fph44$=y1f17}n~N00;P(ALo(xC`UlEeAjM6pYwyvXzNnH?LT^FaDUi4~rPk zT)z68_mh=?6ylhG6aJZhz6zW;wl^HOsBE6|fd?-kiyU;TI)wza{o!ldAT`!Q_Ph?K zYF`cvCMjbdG7Re`H@eF}4<-2OPr*$YH5RoMnVI@;0-X-n%ZoSB^!$P9EdMwvEI*S5 z=^0kxkP9~i9DY2TvFa#y*gf(G>NXp=a-*m6U03c-4dqaZc4bA8S&S+XVS7jx9k==j zA7su{Qsz22{R@fzJv`o1wh>A*(^fN8m%a{uAm1d*bSm`NtdG{9i*3_ET>08Q*IS|Z zeqDU1eSC0>)@YSr+)P3yD5SXrt;YmEBS7$;e)juIp0Eb62m$I?!J4@Tpe*>s_R)X_ zak2QDs{p1Ho9WbaXjE30AH82iLc?dg@khi`=y9a!L3E0m&sJ;Y=Gv5Rx4n7j8Sq3p z<8gF)6j*@PE6$&^$~{1dJOwK-ZFn zYVd&ckX1N13$G2V<|*=R1U$qHB(vG2whCT#%=g0e$~90)>;bCmsFUL=H;1)%H{-)) zl?!;MCk=lS8iIAD?70d!k9vR)G`FidLC@o3fv@Idn_0UECPDq6GY<*-f^`D7=F?D; z8ESV~>n_eUymV`Xb2#+GHK90$4ZIt4;n7ogQ1_c6<*Vk36c}7wp>V0`zae;WZFKKj zwMJeP_KfqD@D^*6=SV3UenXfOWrv%fQcaL|@31@TD;_uP7N?mMDi5DK@XXLl*A zomW4$Ih<(1Olx($xX-2;K&UfZ+{8mT7c#EuQ+AupB?|OtMi!e4^LFxt)a=<)kbZ3eQW{`A$9YKAGuV6<5HSm^xwnu4AtlUg#Oc zo-Mcor(@JJ`EO>u<(D_SZZD%wU%#o_WNk7$gRn@ggZh*BG-yxT3!bsh43U@#jx7!S z|8Rb}bSxcLV}sZc>{xEsR1J~E1BQlRu7wXjjNVn$Iq87yNNbjKd#ggoslDl z-<|vg-!52@oCLqV_+^r0xhxJp!7z_MD0~{XV)V^#`il?}rU>(#%8Xih6}*5(PHHs) zek}<6Kst`#A#qn6t^0oDv5zs}bjM(KA+i)wIQ#Wg-@%x)L*5y!gEZh_!pcu?s-^y! z?gc<&R~zdI+wW%k(29Rbwg&8CNG<;kKt(aDwCd-1uydG)|h@2X?6%Mu`x_!d7i zfxJt?V0|UZ+T-eYSHdkN*(lPnhi^lX@b6<3OU-i|YVe-NVCt}0b*;e1OxNLU_p>+6 z0yp3Lu%82fD+mjjCx0EMQK3Iy{Ri+Zij`s|ltUEWP^rC#zR|!9?+6MZbk}fUj4=d0 zzp}i8`;3n-q!ngWhc-MaUZcCw2ww$I^I=m=9CwuTAn85~9g=rkms~-fq+cXS)Yd~I zmNx%fpc;nTCi_;qk}{0sb__G$Wv@gPgu4`!>tpRtVr3^q$3=}7SUrM>X9D+y;HC&H zr9wgA4f$3#m9T-O4}kxhS%}p|X6sGtK`0aJOHHpMl~w0`yhX#&XB&SlV?J&@to`x z;9KmkUbmtbx9zCvuu!z8Ad08JRbRTWA@D*GklJ`0Dlz*z}N>VoLa<$P$_FVAHyEdz_KiQ9r1- z_sZdQ;0pfDE#yp#v5e}E1HAXx;b<)?hWYFVkylT7J{j-EB-RNn>w=PFkZjO4V`xFo z3Fn4GmV+$#r{C`U=6Jz_pY4@#4g*aMALN{2KrfQS~QhgQq;Gnu=5HH(FdVY=R8 z&(Xtz71%9w_OC|PB(DxY=w=P;gvP_|VGDm$+JB=!lF!j15o=5so)hFvyM%y$XL{$~ z_*{tv^H)zh6q#tL&)V?NpolC`nPEr5o~T+2=P{jL-rbqdEiQY(Rkkf zLX79vv`8;pubgE~t7< zRuF~=l{ELX2B&8K*VpPffv$<)MH!@_`2m1*MWMT}wwsq-e={B))y!2p1zD>U7=|^T zsuw4OC79{gj;y2T;~tU|9!id-^Fx<#ZzIM+33;*#A2wZe$1;jgkoxZE2D@xCi333s z8M`Ydr+Y%k+@X8|=G&YJ`pj&g$gk$mtD7Tf(VzD9&)~H7BNl;8S&FS462D+as%X0u z$Be;L!F3qs)(8dQr!zWI+U&34*Sm;NnYv^N)n>eeH058+#I+$~R*=ceyx)^g5ugO| zr4!fB+@^6ks*E!j&Kqo#jrqG=(>M^KTV^94DW;m8e6~QSU;<4-^7tI%BSz~ z1hZzzVMZ~?d0Z9flh5`=~vVDfTpk9y91L)W5}QT)$RuGrN&wpR)3!3 zlQ-5lrv|k}=_xZXm823(dnG%P(<|H;zmFrWrM$b!W71WbUJ^tV{1Z%wo$5?)UmPH$ z!v7i6|FL7Ul!rcVjChuM^{$z^HpaXVnT@tvplN~0LLZ@70M^m&i)A_v7&#wt3Z z7($u@>*v0Se0Y-BKpZMRWZ{^IF=0kQYa)a(s$|7GI?dDwwG+fc7?e2D6qLi_WJ?Z< zeFmdG@>s5@o$NZ(-C^?FohjTN_*{Ne!3l^`uZmM7#y}fL18Jt3Y^L}e?t7w_mBA$9 zC(`eR%IkI{3+{Mz!Cg&``m>RS``^^cCQVvJLr6iF1ec6ltewB_H|(FsMUuT~nyMEV zUMDq}(6iBQC05rDsE`}^+Yt@Wt6i!1R>p9y z`(UVLTzSsf_aR&};}1&pq<`ZT8KHPgrS+73&wwwl%@Z@!;l9e3JbZDf-U-jc^>U=k zb4#nk%5d*RA&J3*J4U+=?5Wj|vP895^58SZ*Fk5G54UNdsG|+DQGtT)&qZW}zx?ZL zyWu2_fgcE?6G<1RgQe$APh>Fe{rsLO7EZ-RoHzasUvkkFns981avw0GyL7ooaEjDK zG@$$@%Zz+)BpKs3f+Z67_}u4T{0zLa-8mQYUG-okeA>ZMCTrY|q7!IwMNhO&JN6Oi z$O5!d4^UO?=rBLVPAz?RgY`s(Y;w=iw!;~x1oUFE*v+pjHdLN|^_5WJ($_33Z2f9C zcyi50fqCR&2WfEUsalFnI0XFth(C?U^4rJMlc_q|JqSiS`?FA~5WEpkpVtM^*Yf)+ z$>%n@q>o8Gv|rY&4A#Xu|>s|cKLLfY4RvL#L|eg+3(Rw|`hY;>m` zy4`c}1fV#V9*%0Sn?RZaC=EYlS{VuoZN>gotE&jfzB{41?bIXVf%!4+FO#28GR+=i zop`S6vJ5G(e{TqmR?##qQC2{2Z~za2N`D6N*X|U(!%Xhqd zWgO9dt?O!?&J~oCJ6i3M5aF`x%FQ_VWlDR{RO_wR?}e=V++w#S-D2g&kTJ1bpMHUk zN2LYNiQ2yY8=P5UHKV`-&PB+Y1rczhYLC<;{zb;OnsPvwX zG0Xz)nu&<1dQon4W}Tjq|>69loy#4y50PO`jBT zTw8r7(9#Ehp*hjsFB*5f_eHQfi$fs+8Guv)kry4oE4Y7A_=uZFM%QuDUBuhNGvP;O zau!@biKIjWwWEiv zcH_olhJ3Fn_}ZLHB42>!NEsPn+Neg;b=t(qe|kKTJ^@nmh5Wf(gGz>`-N=+1r+^pc)gz}ng` zKU%Z&;B99W7o9Fx=7Sqy34cd^v_&@JT#8K#)&uO<93izlAXfG@?OTqmLnjS@L?%j- z<9JmBuN}^N9F&fwoWCo(wiqy6|L635+xqL_M%00+WX2S;vj8N){a&M;zwH^~_OuzO zvg@fxm`o5+ZMfz4lDbVYf{c2ia7&4aQ$^F_&E|Z;L+<&!;mn+jz_5>+9y+ zX^3#Oi1)?szRsxN8@gXSy`EwMp9BxqED#nJ6Kx9*^yC%jB{c0b9U^b(&B))@Hl6-l zi4BLRv#QuMd2_uTYRR!0FtkC5i?OSe%-D3{BrW=(JeVqj&?crfJCc9El7U1NM?W?D z!;Fpc!}W>f^CG8dHAOisd-+5&?c67q8>qX*wucJ5_WQBe%~!3K1>yIbCpm8RE2n1i z{CQ3osf=4Ge~bsd)dw;U2z7;@rPdr_lsj`32O#d^$OfE8N*`<}1SJ2Ms+eC4o_KV*TT?5lrgmbsmZP)Y=@NKY6LMo+$aA!%k*6PN zVQRLeo|?3)Dyi(|#QuWU)tHfA^jn|R*JDk~ZM#3Od&){)16$FVD7X_(jXzFT8>LdF zY@2%I@6K~SoaFw~n7YG#%ub#o;hfQIfj(=Tp^3oHRv9lVrX8H{X7fhY>4$sN0gx>? z4gf;>BF4h1;!LjJ!MugQ2~@j`+7g-yI+$4zzf*_b^#tGZruMWOq5CF zl(u){W~pv_lUQM5&k}_UKSsyJL3o3vyx9v9KdQj@(52jA&uz4TwxQXN8qOU$wvbl12v* zN1Q=AQcu>Uo-Q9xcXOW4H3-HXxc!@z<|9VNh{YTgKb*eXY3tUeGQTR%h>*r*#(x{Z zRUn~>Iqe)TArv$suAdl&Krq!P1l^l%*xJ~Lm`;dAPgOd)cG-i_n0i2a1zrS!*T*Oi z8gB9D*Wf=TUpQjZm7Xm>lh<#=Sk(S1rJb+;$mJUuDfEl)!M>8u5qSB}G1|4!^@La?= zY>r~Uv-mphhc{V}l@X@E)>IRr&93K;>}bW8W!?23=cpHSR(-M6qA*>|;rx!}CvTDd zldYt$yJZq9A}X?!-bS49B1mY1^qcI51vmcvbMq+XZhJ44v9bCL4J1gQ|7I2=ouPX6 z&%R(B<`y;*a9u*0ZtuMMchfxACh=)q3RET{OQEG=ua@d3=5D65By)0PUgKU|7KxJ|ix z()A59uwRI=E58QhItoOYd3&?syK$O~7klHE{wR8bn2wt)C=-{6qPu0YUG3`o`j`Hs z%Zo13CBK_4C}zf>&T6h|#^qid;-Fu`rlmQ#=P+L{oiObZN$vWNOchskj>^8yd{kjC zUxQ<-^&r1hF;D-yf^$N8!$B_oPB(7Zg%brlJG{aQXwDD!=3xrb#y~wK4WMaq)56#f zUDL|K@(#l#K%;{E6<%AMJivCqiJ;%x&8zTcYTXH;bE&WRtIb6J82*%E>g*6J5R*|| zaO*=9!+A#pg!I1X=d;Ao05O8AMH+uuj%aJ~%;+_jn2n}1@(DsqZ8R(hsSUWdHg493 zjl^s$=0uzn8NMCJsih<`<*Dk*rKop_{>;rBwI|l+Xcqi~<|>=UBMON}>n>` zAVAal*vhR0m3KG8YYdW@cgXf|oI-2nX64y@jdoPF`W%P!2`1 znwc3h4hrYHd@glLnEXBjUAd5wrEM(Mwp{7*Ia=<_8I5Ic$!ALD9uv-030cFWI*4%T zIWutWJ-C}KA3{?x6dv=Z7SSe;L#1fFyW;;^_qy)zS4XNMgq~0<8JpVXE67AxWJfi8 z9TeMjB_oKG0M^0TF)sVHUl8jR3Y3EZphA+UD?;wb2e{6DF=RCz`!k~V>Z3&AiO5~o zU%QR|o=w*QFS094u7ShFHjyrjxXu|>v{uE4`$ z*pwI7YqmTY58tfaqO-gwJp8TVE`X~VI668Ej3=)Tk{&@cg1?reL|pBkX$K`;Tk6?fbDkX=XGnEKTR%FQ;zMq!=<~Py;$`ha=e^Z`Q^p3DvwON6#+VYYJF`R@#Kep1-osyLlB31<&WsB>Wk)$rtcpoVZwj^Ldqn|i0?5C9ErN>p?$$vs1ra^){xq+)ACp|L8w zEQ_QnoxgHLH}$(sO>d#He>VkJUtZQf=1ZG;=1-#Wd$uO6b|%i$6#-1uuEO2EG}x{$ zKNk>M&C>sSWj{m2HsM}lK%&uO`R{hL5>#cL{Dqf2KKJsi`?=y23O$9l(u!@H|Eg{9 zx>o}H({ikRW?9WF=gTNIqM=|V6-cYr?Sw)9#_L93W={I!!Jm(iVi`$s^236bWoEOGXyLFcs4WIP5JXhOPn(i$@%|6w!UJI9JN&vTH~+ab z>T~nKEFXF+ykf&ruBl$%R#$eE?5K7&E4wn)6;ZPDHPpX}BW&Qd?@J9C zy8j5rNOze~`U-FV2ePn}h zH)Avd(iTy8VFK=;Z5K@Ez00?xC}rjol+Tcd{C^dJ3-PcBhk)6S6b-3p$K4t}Q~^w! zIRs{YsA~|hq>;WJ;n2`j4nRQjG;|2iSqN!aaKiO400V4+;7B^@IdP_o;6?5A_QAV_jB&5zY&PFt9wMDGg26 zdC#a-sB{rFS|4pJ@_CTy{$P+uN4B*AWi#U~7h3zFSi?Tay2KzNz27)KB!x&1ny$bA zyt>Fi6;>i0n4-hEq~xtCROj;g>Q|Rm#;-}%ccL?!8ab>40~g7ky)^#!sAIHK9LolIO8t>Jk~U5JjR&n}G%wH0w_vh#j{hC5)D0(xny^ z$yA+n>(sGFIxA6tR)Bw%RC7C<)J;F^G-Zcp!q^JqB~QY*yyFVJI%?%lGqEN5X& zKM@omzfg@=!i>LR{k#uq=0Ixrr4N-KoSrf+EPQiu{On>#E+!~bDXYbjq*`twj$FJX zy(gqAE@UWEd-GkBIAO>Uarq}%)iDlz+q%ZA(Njj@tfU5)_q7pac``Nsf{lUIwbysx zO}LkI#VPDk4lG4jjJuivHzLBlbfEs*YzBiv3_ws7mSGjx1vq7Qoo+8s zGeyLFod;RTw@v|AmvnI+we@^4Fovy54|SYp0WvIU?}TULG0=>;60?_1^1Tr^*VM=B zm0^D{gRIH4c|8lF`R1CaWh`)~`lwd=o}`q6F$XzJe7rS=6Du}ZPKpdR5R-~n$-3L3 zanSv8)(==cJqwJ#J)J_7AqswV@(7=Br$|N8&93ZN#u@qF9wj)*1N0R?83f)c(%cg1 zER|2LCDgDNE8-i1`59nE6^PWhNgLgPe^j8c&zGs{F0!f`%NLpX*=0KQ0=%NiF=gE* z_J!T{GOUxM2RH-*t%ZH%8U5?70q6c{karnf$*G=_C94jF)m|DyX2Vv6<&yz<<2Ea0 zUnDX@vj>4L0}5W{ZuIJV1OVD>D(Nkn;nFyk`h%8JV+**|4VnQ7yX$`PPT@qq}uq?fbRli*u$l)MxH%#mc>i40>mJS zo(rh$f;d4|J#dqMx1`F-OLsiK8>n6)kH~jvP9`fa@<~Y#6at^EKI+?rX0VxrLt0;8 zO^T!X|Bh7}5bAIy{Q}F-=Y)Gl1$_{a9r4Z4;&l4WKbPeQtYy>CnyGlB!c1JEr=mLw zay?wfgLLszeislJVHHifM*v`=y#-kXArY$r7V!js_L+&8rqk;lF{iJ<&SYi22@N|R z)?rPP!(q{MitOKzO}6nb|C_UfoEMwDSj+Kumc-1NGss>Y_*RI31g@yw-X+W4Kx>0h z-r)E!bK5V$MF~{bA3DOAio}zYYXMYPz zdnZyV866H<|05a{$yU6n4WV~uprgHYn8;bdG33mdD1s?~!nD3jL9@nNVcri$lq4qsdmLXLv!TMZOMV97I0ZMoB8K`)q(FOA-LXRmJ zXGV8CsHKW^WDwXTZm-p+P3S?;AO-P*6ng$E!o&qM;NOw_f8*vV(?X+-7o;)y5C9|* zm*d^_?x_q#vQcxaQ)&FkTUT!W4Gs1=jY=ogHj+`MPpXk@ar@L1mPeEH=aIm=y_9RF z&UCo}ALW3=l+tOw3x*8JVqBluA(in_fx2}xs;3-nr*LQoMXj?k5q$PDnuE6w0X10;!V_#9K)F48=SOwixutto>&vK94;yzzSB`P$&=SLx^2f~}!~7-P zEL7ml^rwjnWZsAAnHkj6S|G)%l7q1_QBh$HhP-!G+(xM+`rpZH7?CPvD!b>R=3~p5H#5>A4qLOL*mOCTPvUL2xU$|oiaYnpTM%q4 zW||Vl7>1db221W|#H>s>R1Jrk?!*-{KNZyM!`zDovF(WF97k>n7U%l;R}?&t?Ev2o zq+Z@W*RdRzU^}zK=v2>5s;0DQWSn=>kObbGuSCYf;KVYd@=)8)erZnLjSsx{4 zh*Pcru}_q~bT|og=UFm~Qa2=j9Alzn4Vx#>Rc`sr66DhT0jFp(OluabZ3RC^_a-eY zo-Dy+nACZt>atXy0VIrMq+KlxcL3Ew3B+HTWpB@8yKrQhetU!8q`D;>L}KB98IrBS zV3MLu&lYoiQmDTe@4K6-B_FMj8!y`=jJiV@0LQkYDQT(EdHU<}Bt~o2N1_CTJ@4yX zx2`SLWIN3m(#EG&?Ayrx+cIM$A<l)WcpKM)S3FJ zdLj9g0}@3aO?brmNxji(o23h<%-9C<9|nk*tZA>UgE+lc9xj^HLl#gmlFe!KmHc~k zQ1X$$sU(%V(gv87d3aczKGpWgK>5(ZFog?KhXuH=N^+pqK}8dpOiV9WXP`{Th?0y= zlr^YV-zs|>9w5KPyRR67BV;a1f>~xWrT>{Sg(wme%w}o>l(&L!<1h$nq*;9NNDEhH z`#_nO4Upi;{2aEKVk_B`p@j>~=#xU|0n$3yl|eNS3&}6JsMX2371+Mg^Bu7*ZWu zas=ZlApfx!R1*kTpj1loX%&{FmE}_$Z892Of%mu8oa8X*DV5BrB={mkqrHdxg0MBX z@5)>t`b}8!e^8!`FZS1?H0b*atR8@mkg^hV8)x%~iJ^T5R6&rxcqLFZ0~V|-t2J?* z$kf2bu5EF-Xc=py%=}yZ0Z^Y(#Mz3+Q>t;$PT%XVzUX;|U?;mER&-!J`VxOX#+W8g z#R6@im6YrEVBJ<@AGwL2BKx#b*W>l+kH2SEq`9TS1apvDsrr?kW72VCO%f%8qnz;- g`2TUZ(4M9BA00WfskCGNqnZI!6g1`QWG%!04=T&0GXMYp literal 0 HcmV?d00001 From 70c97a2e2fc1526828feaef149ab3fb0f065ce70 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 11 Apr 2015 00:08:54 +0200 Subject: [PATCH 063/172] FIX donation_direct_debit in multi-company environement (don't use sudo as admin may not be in the same company as the user) Better demo data --- donation/donation.py | 2 +- donation/donation_demo.xml | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 8b73b022b..5d306ded0 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -425,7 +425,7 @@ def _donation_count(self): compute='_donation_count', string="# of Donations", readonly=True) -class account_journal(models.Model): +class AccountJournal(models.Model): _inherit = 'account.journal' allow_donation = fields.Boolean(string='Donation Payment Method') diff --git a/donation/donation_demo.xml b/donation/donation_demo.xml index ccd659f84..7fadc4959 100644 --- a/donation/donation_demo.xml +++ b/donation/donation_demo.xml @@ -38,6 +38,10 @@ + + + + Quest @@ -103,7 +107,7 @@ 120 - + From 23406353bbc594186bd547a65ff125f0f94b4966 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 11 Apr 2015 13:24:27 +0200 Subject: [PATCH 064/172] Adapt YAML test to change in demo data --- donation/test/validate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/donation/test/validate.yml b/donation/test/validate.yml index e6f2fd71a..699930445 100644 --- a/donation/test/validate.yml +++ b/donation/test/validate.yml @@ -23,7 +23,7 @@ !assert {model: donation.donation, id: donation2, string: Donation2 was not correctly validated}: - state == 'done' - move_id.date == time.strftime('%Y-%m-01') - - move_id.journal_id.id == ref('account.cash_journal') + - move_id.journal_id.id == ref('account.bank_journal') - move_id.state == 'posted' - Validate donation3 From 43d295f98aeacab58c4fa874ed97fb6e36904673 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 29 May 2015 13:52:14 +0200 Subject: [PATCH 065/172] Add cancel state on donations Allow to cancel donations linked to a payment line in done state --- donation/donation.py | 24 +++++++++++++++++++++--- donation/donation_view.xml | 9 ++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/donation/donation.py b/donation/donation.py index 5d306ded0..2f721c843 100644 --- a/donation/donation.py +++ b/donation/donation.py @@ -140,6 +140,7 @@ def _default_currency(self): state = fields.Selection([ ('draft', 'Draft'), ('done', 'Done'), + ('cancel', 'Cancel'), ], string='State', readonly=True, copy=False, default='draft', track_visibility='onchange') company_currency_id = fields.Many2one( @@ -320,10 +321,21 @@ def save_default_values(self): return @api.one - def back_to_draft(self): + def done2cancel(self): + '''from Done state to Cancel state''' if self.move_id: self.move_id.button_cancel() self.move_id.unlink() + self.state = 'cancel' + return + + @api.one + def cancel2draft(self): + '''from Cancel state to Draft state''' + if self.move_id: + raise Warning( + _('A cancelled donation should not be linked to an ' + 'account move')) self.state = 'draft' return @@ -332,9 +344,13 @@ def unlink(self): for donation in self: if donation.state == 'done': raise Warning( - _("The donation '%s' is in Done state, so you must " - "set it back to draft before deleting it.") + _("The donation '%s' is in Done state, so you cannot " + "delete it.") % donation.number) + if donation.move_id: + raise Warning( + _("The donation '%s' is linked to an account move, " + "so you cannot delete it.")) return super(DonationDonation, self).unlink() @api.one @@ -342,6 +358,8 @@ def unlink(self): def _compute_display_name(self): if self.state == 'draft': name = _('Draft Donation of %s') % self.partner_id.name + elif self.state == 'cancel': + name = _('Cancelled Donation of %s') % self.partner_id.name else: name = self.number self.display_name = name diff --git a/donation/donation_view.xml b/donation/donation_view.xml index 2ca41e143..66a854595 100644 --- a/donation/donation_view.xml +++ b/donation/donation_view.xml @@ -19,9 +19,12 @@ class="oe_highlight" states="draft" groups="donation.group_donation_user" invisible="context.get('recurring_view')"/> - - - - - + + donation.button.res.partner.form + res.partner + + + + + + + diff --git a/donation/views/users.xml b/donation/views/users.xml index 45d136934..7556d5eb1 100644 --- a/donation/views/users.xml +++ b/donation/views/users.xml @@ -7,32 +7,30 @@ + + donation.res.users.form + res.users + + + + + + + + - - donation.res.users.form - res.users - - - - - - - - - - - donation.preferences.res.users.form - res.users - - - - - - - - - + + donation.preferences.res.users.form + res.users + + + + + + + + diff --git a/donation/wizard/donation_validate.py b/donation/wizard/donation_validate.py index bfd1990c0..cc9b35085 100644 --- a/donation/wizard/donation_validate.py +++ b/donation/wizard/donation_validate.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# © 2014-2016 Barroux Abbey (http://www.barroux.org) -# © 2014-2016 Akretion France (Alexis de Lattre ) +# Copyright 2014-2016 Barroux Abbey (http://www.barroux.org) +# Copyright 2014-2016 Akretion France # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models diff --git a/donation/wizard/donation_validate_view.xml b/donation/wizard/donation_validate_view.xml index 5a0dca259..13b1ea04f 100644 --- a/donation/wizard/donation_validate_view.xml +++ b/donation/wizard/donation_validate_view.xml @@ -1,39 +1,37 @@ + + donation_validate.form + donation.validate + +
+

+ This wizard will validate all the draft donations selected. +

+
+
+
+
+
- - donation_validate.form - donation.validate - -
-

- This wizard will validate all the draft donations selected. -

-
-
-
-
-
- - - +
diff --git a/donation/wizard/tax_receipt_option_switch.py b/donation/wizard/tax_receipt_option_switch.py index ec42f486a..5471b9ed8 100644 --- a/donation/wizard/tax_receipt_option_switch.py +++ b/donation/wizard/tax_receipt_option_switch.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# © 2017 Barroux Abbey (www.barroux.org) -# © 2017 Akretion France (www.akretion.com) +# Copyright 2017 Barroux Abbey (www.barroux.org) +# Copyright 2017 Akretion France (www.akretion.com) # @author Alexis de Lattre @@ -12,12 +12,16 @@ class DonationTaxReceiptOptionSwitch(models.TransientModel): _description = 'Switch Donation Tax Receipt Option' donation_id = fields.Many2one( - 'donation.donation', string='Donation', - default=lambda self: self._context.get('active_id')) + 'donation.donation', + 'Donation', + default=lambda self: self._context.get('active_id') + ) new_tax_receipt_option = fields.Selection([ ('each', 'For Each Donation'), - ('annual', 'Annual Tax Receipt'), - ], string='Tax Receipt Option', required=True) + ('annual', 'Annual Tax Receipt')], + 'Tax Receipt Option', + required=True + ) def switch(self): self.ensure_one() diff --git a/donation/wizard/tax_receipt_option_switch_view.xml b/donation/wizard/tax_receipt_option_switch_view.xml index 12784f93a..7231a86b4 100644 --- a/donation/wizard/tax_receipt_option_switch_view.xml +++ b/donation/wizard/tax_receipt_option_switch_view.xml @@ -1,8 +1,8 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/donation/tests/test_donation.py b/donation/tests/test_donation.py index a564baa94..203ac8063 100644 --- a/donation/tests/test_donation.py +++ b/donation/tests/test_donation.py @@ -3,7 +3,7 @@ import time from odoo.tests.common import TransactionCase -from odoo import tools +from odoo import fields, tools from odoo.modules.module import get_resource_path from odoo.exceptions import ValidationError @@ -101,7 +101,7 @@ def setUp(self): ], }) - def test_donation(self): + def test_donation_1(self): donations = [self.don1, self.don2, self.don3, self.don4, self.don5] for donation in donations: self.assertEquals(donation.state, 'draft') @@ -129,6 +129,31 @@ def test_donation(self): self.assertEquals( donation.tax_receipt_total, tax_receipt.amount) + def test_donation_2(self): + self.donation_id = self.ddo.create({ + 'check_total': 1000, + 'partner_id': self.donor1.id, + 'donation_date': time.strftime('%Y-%m-%d'), + 'journal_id': self.bank_journal.id, + 'tax_receipt_option': 'each', + 'line_ids': [(0, 0, { + 'product_id': self.inkind_product.id, + 'quantity': 1, + 'unit_price': 1000, + })], + }) + self.donation_id.name_get() + self.donation_id.save_default_values() + self.donation_id.partner_id_change() + self.donation_id.tax_receipt_option_change() + self.donation_id.validate() + self.donation_id.line_ids[0]._compute_amount() + self.donation_id.line_ids[0].product_id_change() + self.donation_id.tax_receipt_id = False + self.donation_id.done2cancel() + self.donation_id.cancel2draft() + self.donation_id.unlink() + def test_annual_tax_receipt(self): self.res_partner = self.env['res.partner'] @@ -167,8 +192,12 @@ def test_annual_tax_receipt(self): tax_receipt = tax_receipts[0] self.assertEquals(tax_receipt.amount, 200) self.assertTrue(tax_receipt.number) - self.assertEquals(tax_receipt.date, last_day_year) - self.assertEquals(tax_receipt.donation_date, last_day_year) + self.assertEquals( + tax_receipt.date, fields.Date.from_string(last_day_year) + ) + self.assertEquals( + tax_receipt.donation_date, fields.Date.from_string(last_day_year) + ) self.assertEquals( tax_receipt.currency_id, dons[0].company_id.currency_id) @@ -212,31 +241,6 @@ def test_donation_campaign(self): self.don8.tax_receipt_id = False wizard.switch() - def test_donation(self): - self.donation_id = self.ddo.create({ - 'check_total': 1000, - 'partner_id': self.donor1.id, - 'donation_date': time.strftime('%Y-%m-%d'), - 'journal_id': self.bank_journal.id, - 'tax_receipt_option': 'each', - 'line_ids': [(0, 0, { - 'product_id': self.inkind_product.id, - 'quantity': 1, - 'unit_price': 1000, - })], - }) - self.donation_id.name_get() - self.donation_id.save_default_values() - self.donation_id.partner_id_change() - self.donation_id.tax_receipt_option_change() - self.donation_id.validate() - self.donation_id.line_ids[0]._compute_amount() - self.donation_id.line_ids[0].product_id_change() - self.donation_id.tax_receipt_id = False - self.donation_id.done2cancel() - self.donation_id.cancel2draft() - self.donation_id.unlink() - def create_donation_annual_receipt( self, partner, amount_tax_receipt, amount_no_tax_receipt, payment_ref): diff --git a/donation/views/donation.xml b/donation/views/donation.xml index 6c87caf49..60caf7206 100644 --- a/donation/views/donation.xml +++ b/donation/views/donation.xml @@ -202,8 +202,9 @@ tree,form - + From 33a97322a4d297745ebfd91e508395046a01a11e Mon Sep 17 00:00:00 2001 From: Jaime Arroyo Date: Wed, 29 Jul 2020 10:32:23 +0200 Subject: [PATCH 114/172] [FIX] donation: security issues --- donation/models/partner.py | 6 +----- donation/views/partner.xml | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/donation/models/partner.py b/donation/models/partner.py index 7eabc2ccb..4cdd51216 100644 --- a/donation/models/partner.py +++ b/donation/models/partner.py @@ -10,12 +10,8 @@ class ResPartner(models.Model): @api.depends('donation_ids.partner_id') def _compute_donation_count(self): - # The current user may not have access rights for donations for partner in self: - try: - partner.donation_count = len(partner.donation_ids) - except Exception: - partner.donation_count = 0 + partner.donation_count = len(partner.donation_ids.ids) donation_ids = fields.One2many( 'donation.donation', diff --git a/donation/views/partner.xml b/donation/views/partner.xml index 7360954cd..e598706a0 100644 --- a/donation/views/partner.xml +++ b/donation/views/partner.xml @@ -18,6 +18,7 @@ donation.button.res.partner.form res.partner + - diff --git a/donation/views/users.xml b/donation/views/users.xml index 7556d5eb1..2b93e5ccd 100644 --- a/donation/views/users.xml +++ b/donation/views/users.xml @@ -1,36 +1,38 @@ - + - - donation.res.users.form res.users - + - - + + - donation.preferences.res.users.form res.users - - + + - - + + - diff --git a/donation/wizard/donation_validate.py b/donation/wizard/donation_validate.py index 1c4866c4a..e4733615c 100644 --- a/donation/wizard/donation_validate.py +++ b/donation/wizard/donation_validate.py @@ -6,15 +6,17 @@ class DonationValidate(models.TransientModel): - _name = 'donation.validate' - _description = 'Validate Donations' + _name = "donation.validate" + _description = "Validate Donations" def run(self): self.ensure_one() - assert self.env.context.get('active_model') == 'donation.donation',\ - 'Source model must be donations' - assert self.env.context.get('active_ids'), 'No donations selected' - donations = self.env['donation.donation'].browse( - self.env.context.get('active_ids')) + assert ( + self.env.context.get("active_model") == "donation.donation" + ), "Source model must be donations" + assert self.env.context.get("active_ids"), "No donations selected" + donations = self.env["donation.donation"].browse( + self.env.context.get("active_ids") + ) donations.validate() return diff --git a/donation/wizard/donation_validate_view.xml b/donation/wizard/donation_validate_view.xml index 13b1ea04f..7ea046d18 100644 --- a/donation/wizard/donation_validate_view.xml +++ b/donation/wizard/donation_validate_view.xml @@ -1,37 +1,39 @@ - - + - - donation_validate.form donation.validate - +

This wizard will validate all the draft donations selected.

-
- - - +
diff --git a/donation/wizard/tax_receipt_option_switch.py b/donation/wizard/tax_receipt_option_switch.py index bbb7e7271..65c947960 100644 --- a/donation/wizard/tax_receipt_option_switch.py +++ b/donation/wizard/tax_receipt_option_switch.py @@ -2,30 +2,28 @@ # Copyright 2017 Akretion France (www.akretion.com) # @author Alexis de Lattre -from odoo import models, fields +from odoo import fields, models class DonationTaxReceiptOptionSwitch(models.TransientModel): - _name = 'donation.tax.receipt.option.switch' - _description = 'Switch Donation Tax Receipt Option' + _name = "donation.tax.receipt.option.switch" + _description = "Switch Donation Tax Receipt Option" donation_id = fields.Many2one( - 'donation.donation', - 'Donation', - default=lambda self: self._context.get('active_id') + "donation.donation", + "Donation", + default=lambda self: self._context.get("active_id"), ) - new_tax_receipt_option = fields.Selection([ - ('each', 'For Each Donation'), - ('annual', 'Annual Tax Receipt')], - 'Tax Receipt Option', - required=True + new_tax_receipt_option = fields.Selection( + [("each", "For Each Donation"), ("annual", "Annual Tax Receipt")], + "Tax Receipt Option", + required=True, ) def switch(self): self.ensure_one() - assert self.donation_id, 'Missing donation' - assert not self.donation_id.tax_receipt_id,\ - 'Already linked to a tax receipt' + assert self.donation_id, "Missing donation" + assert not self.donation_id.tax_receipt_id, "Already linked to a tax receipt" self.donation_id.tax_receipt_option = self.new_tax_receipt_option receipt = self.donation_id.generate_each_tax_receipt() if receipt: diff --git a/donation/wizard/tax_receipt_option_switch_view.xml b/donation/wizard/tax_receipt_option_switch_view.xml index 7231a86b4..d25b65420 100644 --- a/donation/wizard/tax_receipt_option_switch_view.xml +++ b/donation/wizard/tax_receipt_option_switch_view.xml @@ -1,5 +1,4 @@ - - + - - donation_tax_receipt_option_switch.form donation.tax.receipt.option.switch - +
- - + +
-
- - + Change Tax Receipt Option donation.tax.receipt.option.switch form new -
From a9c16da5efcbe73bf97fa28cf97047a16e340fcc Mon Sep 17 00:00:00 2001 From: Alba Riera Date: Tue, 22 Jun 2021 18:11:29 +0200 Subject: [PATCH 117/172] [IMP] donation: Migration to 13.0 --- donation/README.rst | 4 +- donation/__manifest__.py | 2 +- donation/models/donation.py | 83 ++++++++++++---------- donation/models/donation_campaign.py | 2 +- donation/security/donation_security.xml | 7 +- donation/tests/test_donation.py | 2 +- donation/views/account.xml | 2 +- donation/views/donation.xml | 8 ++- donation/views/partner.xml | 5 +- donation/wizard/donation_validate_view.xml | 15 ++-- 10 files changed, 68 insertions(+), 62 deletions(-) diff --git a/donation/README.rst b/donation/README.rst index 403e28372..0c417d0de 100644 --- a/donation/README.rst +++ b/donation/README.rst @@ -23,7 +23,7 @@ Donation :target: https://runbot.odoo-community.org/runbot/180/12.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module handles donations, including in-kind donations. When you validate a donation, it will create the corresponding accounting entries. @@ -83,7 +83,7 @@ Contributors * Alexis de Lattre * Serpent Consulting Services Pvt. Ltd. * Nikul Chaudhary - +* Alba Riera Maintainers ~~~~~~~~~~~ diff --git a/donation/__manifest__.py b/donation/__manifest__.py index 8f7b5a8e3..6a1ff4260 100644 --- a/donation/__manifest__.py +++ b/donation/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Donation", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "category": "Accounting & Finance", "license": "AGPL-3", "summary": "Manage donations", diff --git a/donation/models/donation.py b/donation/models/donation.py index 63848ffd0..6d2480898 100644 --- a/donation/models/donation.py +++ b/donation/models/donation.py @@ -25,29 +25,34 @@ class DonationDonation(models.Model): ) def _compute_total(self): for donation in self: - total = tax_receipt_total = 0.0 - for line in donation.line_ids: - line_total = line.quantity * line.unit_price - total += line_total - if line.tax_receipt_ok: - tax_receipt_total += line_total - - donation.amount_total = total - donation_currency = donation.currency_id.with_context( - date=donation.donation_date - ) - company_currency = donation.company_currency_id - total_company_currency = donation_currency._convert( - total, company_currency, donation.company_id, donation.donation_date - ) - tax_receipt_total_cc = donation_currency._convert( - tax_receipt_total, - company_currency, - donation.company_id, - donation.donation_date, - ) - donation.amount_total_company_currency = total_company_currency - donation.tax_receipt_total = tax_receipt_total_cc + if donation.donation_date: + total = tax_receipt_total = 0.0 + for line in donation.line_ids: + line_total = line.quantity * line.unit_price + total += line_total + if line.tax_receipt_ok: + tax_receipt_total += line_total + + donation.amount_total = total + donation_currency = donation.currency_id.with_context( + date=donation.donation_date + ) + company_currency = donation.company_currency_id + total_company_currency = donation_currency._convert( + total, company_currency, donation.company_id, donation.donation_date + ) + tax_receipt_total_cc = donation_currency._convert( + tax_receipt_total, + company_currency, + donation.company_id, + donation.donation_date, + ) + donation.amount_total_company_currency = total_company_currency + donation.tax_receipt_total = tax_receipt_total_cc + else: + donation.amount_total = False + donation.amount_total_company_currency = False + donation.tax_receipt_total = False # We don't want a depends on partner_id.country_id, because if the partner # moves to another country, we want to keep the old country for @@ -59,7 +64,7 @@ def _compute_country_id(self): @api.model def _default_currency(self): - company = self.env["res.company"]._company_default_get("donation.donation") + company = self.env.company return company.currency_id currency_id = fields.Many2one( @@ -67,7 +72,7 @@ def _default_currency(self): string="Currency", required=True, states={"done": [("readonly", True)]}, - track_visibility="onchange", + tracking=True, ondelete="restrict", default=_default_currency, ) @@ -77,7 +82,7 @@ def _default_currency(self): required=True, index=True, states={"done": [("readonly", True)]}, - track_visibility="onchange", + tracking=True, ondelete="restrict", ) commercial_partner_id = fields.Many2one( @@ -105,7 +110,7 @@ def _default_currency(self): string="Check Amount", states={"done": [("readonly", True)]}, currency_field="currency_id", - track_visibility="onchange", + tracking=True, ) amount_total = fields.Monetary( compute="_compute_total", @@ -114,7 +119,7 @@ def _default_currency(self): store=True, compute_sudo=True, readonly=True, - track_visibility="onchange", + tracking=True, ) amount_total_company_currency = fields.Monetary( compute="_compute_total", @@ -129,22 +134,21 @@ def _default_currency(self): required=True, states={"done": [("readonly", True)]}, index=True, - track_visibility="onchange", + tracking=True, ) company_id = fields.Many2one( "res.company", string="Company", required=True, states={"done": [("readonly", True)]}, - default=lambda self: self.env["res.company"]._company_default_get( - "donation.donation" - ), + default=lambda self: self.env.company, ) line_ids = fields.One2many( "donation.line", "donation_id", string="Donation Lines", states={"done": [("readonly", True)]}, + copy=True, ) move_id = fields.Many2one( "account.move", string="Account Move", readonly=True, copy=False @@ -158,7 +162,7 @@ def _default_currency(self): required=True, domain=[("type", "in", ("bank", "cash")), ("allow_donation", "=", True)], states={"done": [("readonly", True)]}, - track_visibility="onchange", + tracking=True, default=lambda self: self.env.user.context_donation_journal_id, ) payment_ref = fields.Char( @@ -171,7 +175,7 @@ def _default_currency(self): copy=False, default="draft", index=True, - track_visibility="onchange", + tracking=True, ) company_currency_id = fields.Many2one( related="company_id.currency_id", @@ -183,8 +187,9 @@ def _default_currency(self): campaign_id = fields.Many2one( "donation.campaign", string="Donation Campaign", - track_visibility="onchange", + tracking=True, ondelete="restrict", + states={"done": [("readonly", True)]}, default=lambda self: self.env.user.context_donation_campaign_id, ) tax_receipt_id = fields.Many2one( @@ -192,7 +197,7 @@ def _default_currency(self): string="Tax Receipt", readonly=True, copy=False, - track_visibility="onchange", + tracking=True, ) tax_receipt_option = fields.Selection( [ @@ -203,7 +208,7 @@ def _default_currency(self): string="Tax Receipt Option", states={"done": [("readonly", True)]}, index=True, - track_visibility="onchange", + tracking=True, ) tax_receipt_total = fields.Monetary( compute="_compute_total", @@ -426,7 +431,7 @@ def validate(self): vals["move_id"] = move.id else: donation.message_post( - _("Full in-kind donation: no account move generated") + body=_("Full in-kind donation: no account move generated") ) receipt = donation.generate_each_tax_receipt() @@ -694,7 +699,7 @@ def update_tax_receipt_annual_dict( ("tax_receipt_option", "=", "annual"), ("tax_receipt_id", "=", False), ("tax_receipt_total", "!=", 0), - ("company_id", "=", self.env.user.company_id.id), + ("company_id", "=", self.env.company.id), ("state", "=", "done"), ] ) diff --git a/donation/models/donation_campaign.py b/donation/models/donation_campaign.py index b26409911..5081a4b31 100644 --- a/donation/models/donation_campaign.py +++ b/donation/models/donation_campaign.py @@ -23,4 +23,4 @@ def name_get(self): code = fields.Char("Code") name = fields.Char("Name", required=True) start_date = fields.Date("Start Date", default=fields.Date.context_today) - note = fields.Text("Notes", oldname="nota") + note = fields.Text("Notes") diff --git a/donation/security/donation_security.xml b/donation/security/donation_security.xml index 6384953d9..a3b8a9390 100644 --- a/donation/security/donation_security.xml +++ b/donation/security/donation_security.xml @@ -39,16 +39,15 @@ Donation Multi-company - ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + + ['|',('company_id','=',False),('company_id','in',company_ids)] Donation Report Multi-company ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])] + >['|',('company_id','=',False),('company_id','in',company_ids)]
diff --git a/donation/tests/test_donation.py b/donation/tests/test_donation.py index 4e6cd3dfd..14996bd2a 100644 --- a/donation/tests/test_donation.py +++ b/donation/tests/test_donation.py @@ -31,7 +31,7 @@ def setUp(self): self._load("account", "test", "account_minimal_test.xml") self.bank_journal = self.env.ref("account.bank_journal") - today = (time.strftime("%Y-%m-%d"),) + today = time.strftime("%Y-%m-%d") self.product = self.env.ref("donation_base.product_product_donation") self.inkind_product = self.env.ref( "donation_base.product_product_inkind_donation" diff --git a/donation/views/account.xml b/donation/views/account.xml index a1c988170..99f94b0c1 100644 --- a/donation/views/account.xml +++ b/donation/views/account.xml @@ -10,7 +10,7 @@ account.journal - + @@ -124,7 +124,11 @@ donation.tree donation.donation - + diff --git a/donation/views/partner.xml b/donation/views/partner.xml index 36d889764..421dca38a 100644 --- a/donation/views/partner.xml +++ b/donation/views/partner.xml @@ -17,12 +17,15 @@ + + + + + + + + + donation.bank.statement.line.form + account.bank.statement.line + + + + + + + + + + + + diff --git a/donation/views/account_journal.xml b/donation/views/account_journal.xml new file mode 100644 index 000000000..8120b5816 --- /dev/null +++ b/donation/views/account_journal.xml @@ -0,0 +1,20 @@ + + + + + + donation.account.journal.form + account.journal + + + + + + + + + + diff --git a/donation/views/account_payment_mode.xml b/donation/views/account_payment_mode.xml new file mode 100644 index 000000000..050f00fac --- /dev/null +++ b/donation/views/account_payment_mode.xml @@ -0,0 +1,32 @@ + + + + + + donation.account.payment.mode.form + account.payment.mode + + + + + + + + + + donation.account.payment.mode.tree + account.payment.mode + + + + + + + + + + + diff --git a/donation/views/donation.xml b/donation/views/donation.xml index 0e7b7acf9..43e1f7b93 100644 --- a/donation/views/donation.xml +++ b/donation/views/donation.xml @@ -1,7 +1,8 @@ @@ -20,6 +21,14 @@ groups="donation.group_donation_user" invisible="context.get('recurring_view')" /> +