Browse Source

[IMP+FIX] account_analytic_analysis_recurring: Several things

* Translations
* Access rules
* README
* Currency for created invoices.
*  #START# and #END# set correctly
* Some conventions
13.0-mig-contract
Pedro M. Baeza 10 years ago
committed by Administrator
parent
commit
880419d29c
  1. 2
      contract/__init__.py
  2. 12
      contract/__openerp__.py
  3. 63
      contract/account_analytic_analysis_recurring.py
  4. 116
      contract/i18n/account_analytic_analysis_recurring.pot
  5. 157
      contract/i18n/es.po
  6. 4
      contract/security/ir.model.access.csv

2
contract/__init__.py

@ -19,4 +19,4 @@
#
##############################################################################
import account_analytic_analysis_recurring
from . import account_analytic_analysis_recurring

12
contract/__openerp__.py

@ -25,14 +25,14 @@
'version': '0.1',
'category': 'Other',
'description': """
This module add a new feature in contracts to manage recurring invoice
======================================================================
This module adds a new feature in contracts to manage recurring invoicing
=========================================================================
This is a backport of the new V8 feature available in trunk and saas. With
the V8 release this module will be deprecated.
It also add a little feature, you can use #START# and #END# in the contract
line to automatically insert the dates of the invoiced period.
It also adds a little feature, you can use #START# and #END# in the contract
line description to automatically insert the dates of the invoiced period.
Backport done By Yannick Buron.
""",
@ -40,12 +40,12 @@ Backport done By Yannick Buron.
'website': 'http://openerp.com',
'depends': ['base', 'account_analytic_analysis'],
'data': [
'security/ir.model.access.csv',
'account_analytic_analysis_recurring_cron.xml',
'account_analytic_analysis_recurring_view.xml',
],
'demo': [''],
'demo': [],
'test': [],
'installable': True,
'images': [],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

63
contract/account_analytic_analysis_recurring.py

@ -23,15 +23,14 @@ import datetime
import logging
import time
from openerp.osv import osv, fields
from openerp.osv import orm, fields
from openerp.tools.translate import _
from openerp.addons.decimal_precision import decimal_precision as dp
_logger = logging.getLogger(__name__)
class account_analytic_invoice_line(osv.osv):
class AccountAnalyticInvoiceLine(orm.Model):
_name = "account.analytic.invoice.line"
def _amount_line(
@ -104,7 +103,7 @@ class account_analytic_invoice_line(osv.osv):
return res_final
class account_analytic_account(osv.osv):
class AccountAnalyticAccount(orm.Model):
_name = "account.analytic.account"
_inherit = "account.analytic.account"
@ -132,6 +131,13 @@ class account_analytic_account(osv.osv):
'recurring_rule_type': 'monthly'
}
def copy(self, cr, uid, id, default=None, context=None):
# Reset next invoice date
default['recurring_next_date'] = \
self._defaults['recurring_next_date']()
return super(AccountAnalyticAccount, self).copy(
cr, uid, id, default=default, context=context)
def onchange_recurring_invoices(
self, cr, uid, ids, recurring_invoices,
date_start=False, context=None):
@ -141,39 +147,36 @@ class account_analytic_account(osv.osv):
return value
def _prepare_invoice(self, cr, uid, contract, context=None):
context = context or {}
if context is None:
context = {}
inv_obj = self.pool.get('account.invoice')
journal_obj = self.pool.get('account.journal')
fpos_obj = self.pool.get('account.fiscal.position')
lang_obj = self.pool.get('res.lang')
if not contract.partner_id:
raise osv.except_osv(
raise orm.except_orm(
_('No Customer Defined!'),
_("You must first select a Customer for Contract %s!") %
contract.name)
fpos = contract.partner_id.property_account_position or False
partner = contract.partner_id
fpos = partner.property_account_position or False
journal_ids = journal_obj.search(
cr, uid,
[('type', '=', 'sale'),
('company_id', '=', contract.company_id.id or False)],
limit=1)
if not journal_ids:
raise osv.except_osv(
raise orm.except_orm(
_('Error!'),
_('Please define a sale journal for the company "%s".') %
(contract.company_id.name or '', ))
partner_payment_term = contract.partner_id.property_payment_term.id
inv_data = {
'reference': contract.code or False,
'account_id': contract.partner_id.property_account_receivable.id,
'account_id': partner.property_account_receivable.id,
'type': 'out_invoice',
'partner_id': contract.partner_id.id,
'currency_id': contract.partner_id.property_product_pricelist.id,
'partner_id': partner.id,
'currency_id': partner.property_product_pricelist.currency_id.id,
'journal_id': len(journal_ids) and journal_ids[0] or False,
'date_invoice': contract.recurring_next_date,
'origin': contract.name,
@ -182,18 +185,14 @@ class account_analytic_account(osv.osv):
'company_id': contract.company_id.id or False,
}
invoice_id = inv_obj.create(cr, uid, inv_data, context=context)
for line in contract.recurring_invoice_line_ids:
res = line.product_id
account_id = res.property_account_income.id
if not account_id:
account_id = res.categ_id.property_account_income_categ.id
account_id = fpos_obj.map_account(cr, uid, fpos, account_id)
taxes = res.taxes_id or False
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
if 'old_date' in context:
lang_ids = lang_obj.search(
cr, uid, [('code', '=', contract.partner_id.lang)],
@ -204,7 +203,6 @@ class account_analytic_account(osv.osv):
'#START#', context['old_date'].strftime(format))
line.name = line.name.replace(
'#END#', context['next_date'].strftime(format))
invoice_line_vals = {
'name': line.name,
'account_id': account_id,
@ -216,42 +214,35 @@ class account_analytic_account(osv.osv):
'invoice_id': invoice_id,
'invoice_line_tax_id': [(6, 0, tax_id)],
}
self.pool.get('account.invoice.line').create(
self.pool['account.invoice.line'].create(
cr, uid, invoice_line_vals, context=context)
inv_obj.button_compute(cr, uid, [invoice_id], context=context)
return invoice_id
def recurring_create_invoice(self, cr, uid, automatic=False, context=None):
context = context or {}
if context is None:
context = {}
current_date = time.strftime('%Y-%m-%d')
contract_ids = self.search(
cr, uid,
[('recurring_next_date', '<=', current_date),
('state', '=', 'open'),
('recurring_invoices', '=', True)])
for contract in self.browse(cr, uid, contract_ids, context=context):
next_date = datetime.datetime.strptime(
contract.recurring_next_date or current_date, "%Y-%m-%d")
interval = contract.recurring_interval
old_date = next_date
if contract.recurring_rule_type == 'daily':
old_date = next_date-relativedelta(days=+interval)
new_date = next_date+relativedelta(days=+interval)
new_date = next_date + relativedelta(days=+interval)
elif contract.recurring_rule_type == 'weekly':
old_date = next_date-relativedelta(weeks=+interval)
new_date = next_date+relativedelta(weeks=+interval)
new_date = next_date + relativedelta(weeks=+interval)
else:
old_date = next_date+relativedelta(months=+interval)
new_date = next_date+relativedelta(months=+interval)
new_date = next_date + relativedelta(months=+interval)
context['old_date'] = old_date
context['next_date'] = datetime.datetime.strptime(
contract.recurring_next_date or current_date, "%Y-%m-%d")
context['next_date'] = new_date
self._prepare_invoice(
cr, uid, contract, context=context)
self.write(
cr, uid, [contract.id],
{'recurring_next_date': new_date.strftime('%Y-%m-%d')},

116
contract/i18n/account_analytic_analysis_recurring.pot

@ -4,49 +4,40 @@
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-02-21 11:41+0000\n"
"PO-Revision-Date: 2014-02-21 11: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: \n"
"Plural-Forms: \n"
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid ". create invoices"
msgstr ""
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid "Account Analytic Lines"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:_description:0
#: field:account.analytic.invoice.line,analytic_account_id:0
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_account
#, python-format
msgid "Analytic Account"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_next_date:0
msgid "Date of Next Invoice"
#: field:account.analytic.invoice.line,price_subtotal:0
msgid "Sub Total"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Day(s)"
#: field:account.analytic.account,recurring_rule_type:0
msgid "Recurrency"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,name:0
msgid "Description"
#: field:account.analytic.invoice.line,price_unit:0
msgid "Unit Price"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:130
#, python-format
msgid "Error!"
#: view:account.analytic.account:0
msgid ". create invoices"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoices:0
msgid "Generate recurring invoices automatically"
#: view:account.analytic.account:0
msgid "Account Analytic Lines"
msgstr ""
#. module: account_analytic_analysis_recurring
@ -55,25 +46,18 @@ msgid "Invoice Lines"
msgstr ""
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_rule_type:0
msgid "Invoice automatically repeat at specified interval"
#: field:account.analytic.invoice.line,uom_id:0
msgid "Unit of Measure"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Month(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:125
#, python-format
msgid "No Customer Defined!"
msgid "Day(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:131
#, python-format
msgid "Please define a sale journal for the company \"%s\"."
#: help:account.analytic.account,recurring_rule_type:0
msgid "Invoice automatically repeat at specified interval"
msgstr ""
#. module: account_analytic_analysis_recurring
@ -82,13 +66,13 @@ msgid "Product"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,quantity:0
msgid "Quantity"
#: field:account.analytic.invoice.line,name:0
msgid "Description"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_rule_type:0
msgid "Recurrency"
#: field:account.analytic.account,recurring_interval:0
msgid "Repeat Every"
msgstr ""
#. module: account_analytic_analysis_recurring
@ -97,49 +81,49 @@ msgid "Recurring Invoices"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_interval:0
msgid "Repeat Every"
#: field:account.analytic.account,recurring_invoices:0
msgid "Generate recurring invoices automatically"
msgstr ""
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_interval:0
msgid "Repeat every (Days/Week/Month/Year)"
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Year(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_subtotal:0
msgid "Sub Total"
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Week(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_unit:0
msgid "Unit Price"
#: field:account.analytic.invoice.line,quantity:0
msgid "Quantity"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,uom_id:0
msgid "Unit of Measure"
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_invoice_line
msgid "account.analytic.invoice.line"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Week(s)"
#: field:account.analytic.account,recurring_next_date:0
msgid "Date of Next Invoice"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Year(s)"
#: field:account.analytic.invoice.line,analytic_account_id:0
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_account
msgid "Analytic Account"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:125
#, python-format
msgid "You must first select a Customer for Contract %s!"
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Month(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:_description:0
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_invoice_line
#, python-format
msgid "account.analytic.invoice.line"
#: help:account.analytic.account,recurring_interval:0
msgid "Repeat every (Days/Week/Month/Year)"
msgstr ""

157
contract/account_analytic_analysis_recurring.pot → contract/i18n/es.po

@ -6,124 +6,151 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-02-21 11:41+0000\n"
"PO-Revision-Date: 2014-02-21 11:41+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2014-08-18 23:13+0000\n"
"PO-Revision-Date: 2014-08-19 01:14+0100\n"
"Last-Translator: Joaquin Gutierrez <joaquing.pedrosa@gmail.com>\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"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_subtotal:0
msgid "Sub Total"
msgstr ""
#: view:account.analytic.account:0
msgid ". create invoices"
msgstr ". crear facturas"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_rule_type:0
msgid "Recurrency"
msgstr ""
#: view:account.analytic.account:0
msgid "Account Analytic Lines"
msgstr "Ver líneas contables analíticas"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_unit:0
msgid "Unit Price"
msgstr ""
#: code:_description:0
#: field:account.analytic.invoice.line,analytic_account_id:0
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_account
#, python-format
msgid "Analytic Account"
msgstr "Cuenta analítica"
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid ". create invoices"
msgstr ""
#: field:account.analytic.account,recurring_next_date:0
msgid "Date of Next Invoice"
msgstr "Próximo fecha de factura"
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid "Account Analytic Lines"
msgstr ""
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Day(s)"
msgstr "Día(s)"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,name:0
msgid "Description"
msgstr "Descripción"
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:165
#, python-format
msgid "Error!"
msgstr "¡Error!"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoices:0
msgid "Generate recurring invoices automatically"
msgstr "Generar facturas recurrentes automáticamente."
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoice_line_ids:0
msgid "Invoice Lines"
msgstr ""
msgstr "Líneas de factura"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,uom_id:0
msgid "Unit of Measure"
msgstr ""
#: help:account.analytic.account,recurring_rule_type:0
msgid "Invoice automatically repeat at specified interval"
msgstr "Repetir factura automáticamente en ese intervalo"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Day(s)"
msgstr ""
msgid "Month(s)"
msgstr "Mes(es)"
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_rule_type:0
msgid "Invoice automatically repeat at specified interval"
msgstr ""
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:153
#, python-format
msgid "No Customer Defined!"
msgstr "¡No se ha definido un cliente!"
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:166
#, python-format
msgid "Please define a sale journal for the company \"%s\"."
msgstr "Defina por favor un diario de ventas para esta compañía \"%s\"."
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,product_id:0
msgid "Product"
msgstr ""
msgstr "Producto"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,name:0
msgid "Description"
msgstr ""
#: field:account.analytic.invoice.line,quantity:0
msgid "Quantity"
msgstr "Cantidad"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_interval:0
msgid "Repeat Every"
msgstr ""
#: field:account.analytic.account,recurring_rule_type:0
msgid "Recurrency"
msgstr "Recurrencia"
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid "Recurring Invoices"
msgstr ""
msgstr "Facturas recurrentes"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoices:0
msgid "Generate recurring invoices automatically"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Year(s)"
msgstr ""
#: field:account.analytic.account,recurring_interval:0
msgid "Repeat Every"
msgstr "Repetir cada"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Week(s)"
msgstr ""
#: help:account.analytic.account,recurring_interval:0
msgid "Repeat every (Days/Week/Month/Year)"
msgstr "Repetir cada (días/semana/mes/año)"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,quantity:0
msgid "Quantity"
msgstr ""
#: field:account.analytic.invoice.line,price_subtotal:0
msgid "Sub Total"
msgstr "Subtotal"
#. module: account_analytic_analysis_recurring
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_invoice_line
msgid "account.analytic.invoice.line"
msgstr ""
#: field:account.analytic.invoice.line,price_unit:0
msgid "Unit Price"
msgstr "Precio unidad"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_next_date:0
msgid "Date of Next Invoice"
msgstr ""
#: field:account.analytic.invoice.line,uom_id:0
msgid "Unit of Measure"
msgstr "Unidad de medida"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,analytic_account_id:0
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_account
msgid "Analytic Account"
msgstr ""
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Week(s)"
msgstr "Semana(s)"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Month(s)"
msgstr ""
msgid "Year(s)"
msgstr "Año(s)"
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_interval:0
msgid "Repeat every (Days/Week/Month/Year)"
msgstr ""
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:154
#, python-format
msgid "You must first select a Customer for Contract %s!"
msgstr "¡Seleccione un cliente para este contrato %s!"
#. module: account_analytic_analysis_recurring
#: code:_description:0
#: model:ir.model,name:account_analytic_analysis_recurring.model_account_analytic_invoice_line
#, python-format
msgid "account.analytic.invoice.line"
msgstr "account.analytic.invoice.line"

4
contract/security/ir.model.access.csv

@ -0,0 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"account_analytic_invoice_line_manager","Recurring manager","model_account_analytic_invoice_line","base.group_sale_manager",1,1,1,1
"account_analytic_invoice_line_user","Recurring user","model_account_analytic_invoice_line","base.group_sale_salesman",1,0,0,0
Loading…
Cancel
Save