Merge lp:~domsense/domsense-agilebg-addons/adding_causali into lp:domsense-agilebg-addons/6.0

Proposed by Davide Corio
Status: Rejected
Rejected by: Lorenzo Battistini
Proposed branch: lp:~domsense/domsense-agilebg-addons/adding_causali
Merge into: lp:domsense-agilebg-addons/6.0
Diff against target: 550 lines (+519/-0)
6 files modified
account_recurring_model/AUTHORS.txt (+1/-0)
account_recurring_model/__init__.py (+22/-0)
account_recurring_model/__openerp__.py (+35/-0)
account_recurring_model/account_model.py (+231/-0)
account_recurring_model/account_model_view.xml (+89/-0)
account_recurring_model/i18n/it.po (+141/-0)
To merge this branch: bzr merge lp:~domsense/domsense-agilebg-addons/adding_causali
Reviewer Review Type Date Requested Status
Lorenzo Battistini Needs Information
Review via email: mp+73954@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Non si riesce a usare 'super' nei metodi 'generate' e 'create_entries' ?

review: Needs Information
Revision history for this message
Davide Corio (enlightx-deactivatedaccount) wrote :

ad occhio direi di no, ma sarei felice di essere smentito

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Lo consideriamo sostituito da account_move_template e account_invoice_template?

Unmerged revisions

22. By Davide Corio

[ADD] new reg wizard

21. By Davide Corio

[FIX] missing import

20. By Davide Corio

[IMP] dedicated menu item and translations

19. By Davide Corio

[FIX] pdb removed

18. By Davide Corio

[IMP] tax computation

17. By Davide Corio

[IMP] added tax_code on model line

16. By Lorenzo Battistini

[DEL] account_voucher_template

15. By Lorenzo Battistini

[FIX] varie

14. By Lorenzo Battistini

[FIX] mandatory field

13. By Lorenzo Battistini

[add] account_recurring_model account_voucher_template

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'account_recurring_model'
=== added file 'account_recurring_model/AUTHORS.txt'
--- account_recurring_model/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ account_recurring_model/AUTHORS.txt 2011-09-03 19:18:23 +0000
@@ -0,0 +1,1 @@
1Davide Corio <davide.corio@agilebg.com>
02
=== added file 'account_recurring_model/__init__.py'
--- account_recurring_model/__init__.py 1970-01-01 00:00:00 +0000
+++ account_recurring_model/__init__.py 2011-09-03 19:18:23 +0000
@@ -0,0 +1,22 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import account_model
023
=== added file 'account_recurring_model/__openerp__.py'
--- account_recurring_model/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_recurring_model/__openerp__.py 2011-09-03 19:18:23 +0000
@@ -0,0 +1,35 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 'name': 'Account Recurring Models',
23 'version': '0.1',
24 'category': 'Generic Modules/Accounting',
25 'description': """Account Recurring Models (Improvements)""",
26 'author': 'Agile Business Group & Domsense',
27 'website': 'http://www.agilebg.com',
28 'license': 'AGPL-3',
29 "depends" : ['account'],
30 "init_xml" : ['account_model_view.xml'],
31 "update_xml" : [],
32 "demo_xml" : [],
33 "active": False,
34 "installable": True
35}
036
=== added file 'account_recurring_model/account_model.py'
--- account_recurring_model/account_model.py 1970-01-01 00:00:00 +0000
+++ account_recurring_model/account_model.py 2011-09-03 19:18:23 +0000
@@ -0,0 +1,231 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C) 2011 Domsense s.r.l. (<http://www.domsense.com>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import datetime
23import time
24import decimal_precision as dp
25
26from osv import fields, osv
27from tools.translate import _
28
29
30class account_model_line(osv.osv):
31
32 _inherit = 'account.model.line'
33 _columns = {
34 'type':fields.selection([
35 ('cr','Credit'),
36 ('dr','Debit'),
37 ], 'Type'),
38 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
39 'value_type': fields.selection([
40 ('amount','Amount'),
41 ('percentage','Percentage'),
42 ], 'Value Type'),
43 'account_tax_id': fields.many2one('account.tax','Tax'),
44 }
45
46 def compute_amount(self,vals,amount):
47 if vals['type']=='cr' and vals['value_type']=='amount':
48 vals['credit']=vals['amount']
49 elif vals['type']=='cr' and vals['value_type']=='percentage':
50 vals['credit']=(amount/100)*vals['amount']
51 elif vals['type']=='dr' and vals['value_type']=='amount':
52 vals['debit']=vals['amount']
53 elif vals['type']=='dr' and vals['value_type']=='percentage':
54 vals['debit']=(amount/100)*vals['amount']
55 return vals
56
57 def create(self, cr, uid, vals, context=None):
58 amount = self.pool.get('account.model').browse(cr,uid,vals['model_id']).amount
59 vals = self.compute_amount(vals,amount)
60 return super(account_model_line, self).create(cr, uid, vals, context)
61
62 def write(self, cr, uid, ids, vals, context=None):
63 amount = self.pool.get('account.model.line').browse(cr,uid,ids[0]).model_id.amount
64 vals = self.compute_amount(vals,amount)
65 return super(account_model_line, self).write(cr, uid, ids, vals, context=context)
66
67account_model_line()
68
69class account_model(osv.osv):
70
71 _inherit = 'account.model'
72 _columns = {
73 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
74 }
75
76 def generate(self, cr, uid, ids, datas={}, context=None):
77 move_ids = []
78 entry = {}
79 account_move_obj = self.pool.get('account.move')
80 account_move_line_obj = self.pool.get('account.move.line')
81 pt_obj = self.pool.get('account.payment.term')
82
83 if context is None:
84 context = {}
85
86 if datas.get('date', False):
87 context.update({'date': datas['date']})
88
89 period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
90 if not period_id:
91 raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
92 period_id = period_id[0]
93
94 for model in self.browse(cr, uid, ids, context=context):
95 entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')}
96 move_id = account_move_obj.create(cr, uid, {
97 'ref': entry['name'],
98 'period_id': period_id,
99 'journal_id': model.journal_id.id,
100 'date': context.get('date',time.strftime('%Y-%m-%d'))
101 })
102 move_ids.append(move_id)
103 for line in model.lines_id:
104 analytic_account_id = False
105 if line.analytic_account_id:
106 if not model.journal_id.analytic_journal_id:
107 raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,))
108 analytic_account_id = line.analytic_account_id.id
109 val = {
110 'move_id': move_id,
111 'journal_id': model.journal_id.id,
112 'period_id': period_id,
113 'analytic_account_id': analytic_account_id
114 }
115
116 date_maturity = time.strftime('%Y-%m-%d')
117 if line.date_maturity == 'partner':
118 if not line.partner_id:
119 raise osv.except_osv(_('Error !'), _("Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!" \
120 "\nPlease define partner on it!")%(line.name, model.name))
121 if line.partner_id.property_payment_term:
122 payment_term_id = line.partner_id.property_payment_term.id
123 pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_maturity)
124 if pterm_list:
125 pterm_list = [l[0] for l in pterm_list]
126 pterm_list.sort()
127 date_maturity = pterm_list[-1]
128
129 val.update({
130 'name': line.name,
131 'quantity': line.quantity,
132 'debit': line.debit,
133 'credit': line.credit,
134 'account_id': line.account_id.id,
135 'move_id': move_id,
136 'partner_id': line.partner_id.id,
137 'date': context.get('date',time.strftime('%Y-%m-%d')),
138 'date_maturity': date_maturity,
139 'account_tax_id': line.account_tax_id.id,
140 })
141 c = context.copy()
142 c.update({'journal_id': model.journal_id.id,'period_id': period_id})
143 account_move_line_obj.create(cr, uid, val, context=c)
144
145 return move_ids
146
147account_model()
148
149class account_use_model(osv.osv_memory):
150
151 _inherit = 'account.use.model'
152
153 def create_entries(self, cr, uid, ids, context=None):
154 account_model_obj = self.pool.get('account.model')
155 account_period_obj = self.pool.get('account.period')
156 account_move_obj = self.pool.get('account.move')
157 account_move_line_obj = self.pool.get('account.move.line')
158 pt_obj = self.pool.get('account.payment.term')
159 mod_obj = self.pool.get('ir.model.data')
160 if context is None:
161 context = {}
162 move_ids = []
163 entry = {}
164 data = self.read(cr, uid, ids, context=context)[0]
165 record_id = context and context.get('model_line', False) or False
166 if record_id:
167 data_model = account_model_obj.browse(cr, uid, data['model'], context=context)
168 else:
169 data_model = account_model_obj.browse(cr, uid, context['active_ids'], context=context)
170 for model in data_model:
171 entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%d')}
172 period_id = account_period_obj.find(cr, uid, context=context)
173 if not period_id:
174 raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
175 period_id = period_id[0]
176 move_id = account_move_obj.create(cr, uid, {
177 'ref': entry['name'],
178 'period_id': period_id,
179 'journal_id': model.journal_id.id,
180 })
181 move_ids.append(move_id)
182 for line in model.lines_id:
183 analytic_account_id = False
184 if line.analytic_account_id:
185 if not model.journal_id.analytic_journal_id:
186 raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,))
187 analytic_account_id = line.analytic_account_id.id
188 val = {
189 'move_id': move_id,
190 'journal_id': model.journal_id.id,
191 'period_id': period_id,
192 'analytic_account_id': analytic_account_id
193 }
194 date_maturity = time.strftime('%Y-%m-%d')
195 if line.date_maturity == 'partner' and line.partner_id and line.partner_id.property_payment_term:
196 payment_term_id = line.partner_id.property_payment_term.id
197 pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_maturity)
198 if pterm_list:
199 pterm_list = [l[0] for l in pterm_list]
200 pterm_list.sort()
201 date_maturity = pterm_list[-1]
202 val.update({
203 'name': line.name,
204 'quantity': line.quantity,
205 'debit': line.debit,
206 'credit': line.credit,
207 'account_id': line.account_id.id,
208 'move_id': move_id,
209 'partner_id': line.partner_id.id,
210 'date': time.strftime('%Y-%m-%d'),
211 'date_maturity': date_maturity,
212 'account_tax_id': line.account_tax_id.id,
213 })
214 c = context.copy()
215 c.update({'journal_id': model.journal_id.id,'period_id': period_id})
216 id_line = account_move_line_obj.create(cr, uid, val, context=c)
217
218 context.update({'move_ids':move_ids})
219 model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_move_form')], context=context)
220 resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
221 return {
222 'domain': "[('id','in', ["+','.join(map(str,context['move_ids']))+"])]",
223 'name': 'Entries',
224 'view_type': 'form',
225 'view_mode': 'tree,form',
226 'res_model': 'account.move',
227 'views': [(False,'tree'),(resource_id,'form')],
228 'type': 'ir.actions.act_window',
229 }
230
231account_use_model()
0232
=== added file 'account_recurring_model/account_model_view.xml'
--- account_recurring_model/account_model_view.xml 1970-01-01 00:00:00 +0000
+++ account_recurring_model/account_model_view.xml 2011-09-03 19:18:23 +0000
@@ -0,0 +1,89 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<openerp>
3 <data>
4
5 <record id="view_model_line_form_type" model="ir.ui.view">
6 <field name="name">account.model.line.form.type</field>
7 <field name="model">account.model.line</field>
8 <field name="inherit_id" ref="account.view_model_line_form"/>
9 <field name="arch" type="xml">
10 <field name="partner_id" position="after">
11 <field name="type"/>
12 </field>
13 </field>
14 </record>
15
16 <record id="view_model_form_amount" model="ir.ui.view">
17 <field name="name">account.model.form.amount</field>
18 <field name="model">account.model</field>
19 <field name="inherit_id" ref="account.view_model_form"/>
20 <field name="arch" type="xml">
21 <field name="name" position="after">
22 <field name="amount"/>
23 </field>
24 </field>
25 </record>
26
27 <record id="view_model_line_tree_type" model="ir.ui.view">
28 <field name="name">account.model.line.tree.type</field>
29 <field name="model">account.model.line</field>
30 <field name="inherit_id" ref="account.view_model_line_tree"/>
31 <field name="arch" type="xml">
32 <field name="partner_id" position="after">
33 <field name="type"/>
34 </field>
35 </field>
36 </record>
37
38 <record id="view_model_line_tree_amount_1" model="ir.ui.view">
39 <field name="name">account.model.line.tree.amount.1</field>
40 <field name="model">account.model.line</field>
41 <field name="inherit_id" ref="account.view_model_line_tree"/>
42 <field name="arch" type="xml">
43 <field name="credit" position="replace">
44 </field>
45 </field>
46 </record>
47
48 <record id="view_model_line_tree_amount_2" model="ir.ui.view">
49 <field name="name">account.model.line.tree.amount.2</field>
50 <field name="model">account.model.line</field>
51 <field name="inherit_id" ref="account.view_model_line_tree"/>
52 <field name="arch" type="xml">
53 <field name="debit" position="replace">
54 <field name="value_type"/>
55 <field name="amount"/>
56 <field name="account_tax_id"/>
57 </field>
58 </field>
59 </record>
60
61 <record id="view_model_line_form_amount_1" model="ir.ui.view">
62 <field name="name">account.model.line.form.amount.1</field>
63 <field name="model">account.model.line</field>
64 <field name="inherit_id" ref="account.view_model_line_form"/>
65 <field name="arch" type="xml">
66 <field name="credit" position="replace">
67 </field>
68 </field>
69 </record>
70
71 <record id="view_model_line_form_amount_2" model="ir.ui.view">
72 <field name="name">account.model.line.form.amount.2</field>
73 <field name="model">account.model.line</field>
74 <field name="inherit_id" ref="account.view_model_line_form"/>
75 <field name="arch" type="xml">
76 <field name="debit" position="replace">
77 <field name="value_type"/>
78 <field name="amount"/>
79 <field name="account_tax_id"/>
80 </field>
81 </field>
82 </record>
83
84 <menuitem
85 action="account.action_model_form" name="Recurring Models" id="menu_action_recurring_model_form" sequence="5" parent="account.menu_finance_entries" groups="base.group_extended"/>
86 <menuitem name="Create Entries from Model" action="account.action_view_account_use_model" id="menu_action_manual_recurring" sequence="10" parent="account.menu_finance_entries"/>
87
88 </data>
89</openerp>
090
=== added directory 'account_recurring_model/i18n'
=== added file 'account_recurring_model/i18n/it.po'
--- account_recurring_model/i18n/it.po 1970-01-01 00:00:00 +0000
+++ account_recurring_model/i18n/it.po 2011-09-03 19:18:23 +0000
@@ -0,0 +1,141 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_recurring_model
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.0.2\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"
9"POT-Creation-Date: 2011-09-03 15:29+0000\n"
10"PO-Revision-Date: 2011-09-03 15:29+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: account_recurring_model
19#: code:addons/account_recurring_model/account_model.py:107
20#: code:addons/account_recurring_model/account_model.py:186
21#, python-format
22msgid "You have to define an analytic journal on the '%s' journal!"
23msgstr "E' necessario definire un giornale analitico sul sezionale '%s'!"
24
25#. module: account_recurring_model
26#: selection:account.model.line,type:0
27msgid "Debit"
28msgstr "Dare"
29
30#. module: account_recurring_model
31#: model:ir.ui.menu,name:account_recurring_model.menu_action_manual_recurring
32msgid "Create Entries from Model"
33msgstr "Crea registrazioni da causale"
34
35#. module: account_recurring_model
36#: field:account.model.line,type:0
37msgid "Type"
38msgstr "Tipo"
39
40#. module: account_recurring_model
41#: selection:account.model.line,value_type:0
42msgid "Percentage"
43msgstr "Percentuale"
44
45#. module: account_recurring_model
46#: code:addons/account_recurring_model/account_model.py:119
47#, python-format
48msgid "Error !"
49msgstr "Errore !"
50
51#. module: account_recurring_model
52#: model:ir.module.module,description:account_recurring_model.module_meta_information
53msgid "Account Recurring Models (Improvements)"
54msgstr "Account Recurring Models (Improvements)"
55
56#. module: account_recurring_model
57#: code:addons/account_recurring_model/account_model.py:119
58#, python-format
59msgid "Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!\n"
60"Please define partner on it!"
61msgstr "Maturity date of entry line generated by model line '%s' of model '%s' is based on partner payment term!\n"
62"Please define partner on it!"
63
64#. module: account_recurring_model
65#: model:ir.ui.menu,name:account_recurring_model.menu_action_recurring_model_form
66msgid "Recurring Models"
67msgstr "Modelli Causale"
68
69#. module: account_recurring_model
70#: model:ir.model,name:account_recurring_model.model_account_model
71msgid "Account Model"
72msgstr "Modello Causale"
73
74#. module: account_recurring_model
75#: sql_constraint:account.model.line:0
76msgid "Wrong credit or debit value in model (Credit Or Debit Must Be \"0\")!"
77msgstr "Errato valore per il credito od il debito nel modello (uno dei due deve essere \"0\") !"
78
79#. module: account_recurring_model
80#: sql_constraint:account.model.line:0
81msgid "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
82msgstr "Valore del credito o debito errato (credito+debito deve essere maggiore di \"0\")!"
83
84#. module: account_recurring_model
85#: model:ir.model,name:account_recurring_model.model_account_model_line
86msgid "Account Model Entries"
87msgstr "Voci Modello Causale"
88
89#. module: account_recurring_model
90#: selection:account.model.line,type:0
91msgid "Credit"
92msgstr "Avere"
93
94#. module: account_recurring_model
95#: field:account.model,amount:0
96#: field:account.model.line,amount:0
97#: selection:account.model.line,value_type:0
98msgid "Amount"
99msgstr "Importo"
100
101#. module: account_recurring_model
102#: model:ir.model,name:account_recurring_model.model_account_use_model
103msgid "Use model"
104msgstr "Usa il modello"
105
106#. module: account_recurring_model
107#: model:ir.module.module,shortdesc:account_recurring_model.module_meta_information
108msgid "Account Recurring Models"
109msgstr "Account Recurring Models"
110
111#. module: account_recurring_model
112#: code:addons/account_recurring_model/account_model.py:91
113#: code:addons/account_recurring_model/account_model.py:174
114#, python-format
115msgid "Unable to find a valid period !"
116msgstr "Impossibile trovare un periodo valido!"
117
118#. module: account_recurring_model
119#: field:account.model.line,value_type:0
120msgid "Value Type"
121msgstr "Tipo Valore"
122
123#. module: account_recurring_model
124#: code:addons/account_recurring_model/account_model.py:107
125#: code:addons/account_recurring_model/account_model.py:186
126#, python-format
127msgid "No Analytic Journal !"
128msgstr "No Analytic Journal !"
129
130#. module: account_recurring_model
131#: field:account.model.line,account_tax_id:0
132msgid "Tax"
133msgstr "Tassa"
134
135#. module: account_recurring_model
136#: code:addons/account_recurring_model/account_model.py:91
137#: code:addons/account_recurring_model/account_model.py:174
138#, python-format
139msgid "No period found !"
140msgstr "No period found !"
141

Subscribers

People subscribed via source and target branches

to status/vote changes: