Browse Source

[IMP+FIX] Pot file and Dutch translation + PEP8

13.0-mig-contract
Stefan Rijnhart 11 years ago
committed by Administrator
parent
commit
2c4b809529
  1. 9
      contract/__openerp__.py
  2. 134
      contract/account_analytic_analysis_recurring.py
  3. 145
      contract/i18n/account_analytic_analysis_recurring.pot
  4. 156
      contract/i18n/nl.po

9
contract/__openerp__.py

@ -26,10 +26,13 @@
'category': 'Other', 'category': 'Other',
'description': """ 'description': """
This module add a new feature in contracts to manage recurring invoice This module add a new feature in contracts to manage recurring invoice
=======================================================================================
======================================================================
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.
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.
Backport done By Yannick Buron. Backport done By Yannick Buron.
""", """,

134
contract/account_analytic_analysis_recurring.py

@ -24,62 +24,82 @@ import logging
import time import time
from openerp.osv import osv, fields from openerp.osv import osv, fields
from openerp.osv.orm import intersect, except_orm
import openerp.tools
from openerp.tools.translate import _ from openerp.tools.translate import _
from openerp.addons.decimal_precision import decimal_precision as dp from openerp.addons.decimal_precision import decimal_precision as dp
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class account_analytic_invoice_line(osv.osv): class account_analytic_invoice_line(osv.osv):
_name = "account.analytic.invoice.line" _name = "account.analytic.invoice.line"
def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict, context=None):
def _amount_line(
self, cr, uid, ids, prop, unknow_none, unknow_dict, context=None):
res = {} res = {}
for line in self.browse(cr, uid, ids, context=context): for line in self.browse(cr, uid, ids, context=context):
res[line.id] = line.quantity * line.price_unit res[line.id] = line.quantity * line.price_unit
if line.analytic_account_id.pricelist_id: if line.analytic_account_id.pricelist_id:
cur = line.analytic_account_id.pricelist_id.currency_id cur = line.analytic_account_id.pricelist_id.currency_id
res[line.id] = self.pool.get('res.currency').round(cr, uid, cur, res[line.id])
res[line.id] = self.pool.get('res.currency').round(
cr, uid, cur, res[line.id])
return res return res
_columns = { _columns = {
'product_id': fields.many2one('product.product','Product',required=True),
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
'product_id': fields.many2one(
'product.product', 'Product', required=True),
'analytic_account_id': fields.many2one(
'account.analytic.account', 'Analytic Account'),
'name': fields.text('Description', required=True), 'name': fields.text('Description', required=True),
'quantity': fields.float('Quantity', required=True), 'quantity': fields.float('Quantity', required=True),
'uom_id': fields.many2one('product.uom', 'Unit of Measure',required=True),
'uom_id': fields.many2one(
'product.uom', 'Unit of Measure', required=True),
'price_unit': fields.float('Unit Price', required=True), 'price_unit': fields.float('Unit Price', required=True),
'price_subtotal': fields.function(_amount_line, string='Sub Total', type="float",digits_compute= dp.get_precision('Account')),
'price_subtotal': fields.function(
_amount_line, string='Sub Total',
type="float", digits_compute=dp.get_precision('Account')),
} }
_defaults = { _defaults = {
'quantity': 1, 'quantity': 1,
} }
def product_id_change(self, cr, uid, ids, product, uom_id, qty=0, name='', partner_id=False, price_unit=False, pricelist_id=False, company_id=None, context=None):
def product_id_change(
self, cr, uid, ids, product, uom_id, qty=0, name='',
partner_id=False, price_unit=False, pricelist_id=False,
company_id=None, context=None):
context = context or {} context = context or {}
uom_obj = self.pool.get('product.uom') uom_obj = self.pool.get('product.uom')
company_id = company_id or False company_id = company_id or False
context.update({'company_id': company_id, 'force_company': company_id, 'pricelist_id': pricelist_id})
context.update(
{'company_id': company_id,
'force_company': company_id,
'pricelist_id': pricelist_id})
if not product: if not product:
return {'value': {'price_unit': 0.0}, 'domain':{'product_uom':[]}}
return {
'value': {'price_unit': 0.0},
'domain': {'product_uom': []}}
if partner_id: if partner_id:
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)
part = self.pool.get('res.partner').browse(
cr, uid, partner_id, context=context)
if part.lang: if part.lang:
context.update({'lang': part.lang}) context.update({'lang': part.lang})
result = {} result = {}
res = self.pool.get('product.product').browse(cr, uid, product, context=context)
result.update({'name':res.partner_ref or False,'uom_id': uom_id or res.uom_id.id or False, 'price_unit': res.list_price or 0.0})
res = self.pool.get('product.product').browse(
cr, uid, product, context=context)
result.update(
{'name': res.partner_ref or False,
'uom_id': uom_id or res.uom_id.id or False,
'price_unit': res.list_price or 0.0})
if res.description: if res.description:
result['name'] += '\n'+res.description result['name'] += '\n'+res.description
res_final = {'value': result} res_final = {'value': result}
if result['uom_id'] != res.uom_id.id: if result['uom_id'] != res.uom_id.id:
selected_uom = uom_obj.browse(cr, uid, result['uom_id'], context=context)
new_price = uom_obj._compute_price(cr, uid, res.uom_id.id, res_final['value']['price_unit'], result['uom_id'])
new_price = uom_obj._compute_price(
cr, uid, res.uom_id.id,
res_final['value']['price_unit'], result['uom_id'])
res_final['value']['price_unit'] = new_price res_final['value']['price_unit'] = new_price
return res_final return res_final
@ -89,15 +109,20 @@ class account_analytic_account(osv.osv):
_inherit = "account.analytic.account" _inherit = "account.analytic.account"
_columns = { _columns = {
'recurring_invoice_line_ids': fields.one2many('account.analytic.invoice.line', 'analytic_account_id', 'Invoice Lines'),
'recurring_invoices' : fields.boolean('Generate recurring invoices automatically'),
'recurring_rule_type': fields.selection([
('daily', 'Day(s)'),
'recurring_invoice_line_ids': fields.one2many(
'account.analytic.invoice.line', 'analytic_account_id',
'Invoice Lines'),
'recurring_invoices': fields.boolean(
'Generate recurring invoices automatically'),
'recurring_rule_type': fields.selection(
[('daily', 'Day(s)'),
('weekly', 'Week(s)'), ('weekly', 'Week(s)'),
('monthly', 'Month(s)'), ('monthly', 'Month(s)'),
('yearly', 'Year(s)'), ('yearly', 'Year(s)'),
], 'Recurrency', help="Invoice automatically repeat at specified interval"),
'recurring_interval': fields.integer('Repeat Every', help="Repeat every (Days/Week/Month/Year)"),
], 'Recurrency',
help="Invoice automatically repeat at specified interval"),
'recurring_interval': fields.integer(
'Repeat Every', help="Repeat every (Days/Week/Month/Year)"),
'recurring_next_date': fields.date('Date of Next Invoice'), 'recurring_next_date': fields.date('Date of Next Invoice'),
} }
@ -107,7 +132,9 @@ class account_analytic_account(osv.osv):
'recurring_rule_type': 'monthly' 'recurring_rule_type': 'monthly'
} }
def onchange_recurring_invoices(self, cr, uid, ids, recurring_invoices, date_start=False, context=None):
def onchange_recurring_invoices(
self, cr, uid, ids, recurring_invoices,
date_start=False, context=None):
value = {} value = {}
if date_start and recurring_invoices: if date_start and recurring_invoices:
value = {'value': {'recurring_next_date': date_start}} value = {'value': {'recurring_next_date': date_start}}
@ -122,23 +149,31 @@ class account_analytic_account(osv.osv):
lang_obj = self.pool.get('res.lang') lang_obj = self.pool.get('res.lang')
if not contract.partner_id: if not contract.partner_id:
raise osv.except_osv(_('No Customer Defined!'),_("You must first select a Customer for Contract %s!") % contract.name )
raise osv.except_osv(
_('No Customer Defined!'),
_("You must first select a Customer for Contract %s!") %
contract.name)
fpos = contract.partner_id.property_account_position or False fpos = contract.partner_id.property_account_position or False
journal_ids = journal_obj.search(cr, uid, [('type', '=','sale'),('company_id', '=', contract.company_id.id or False)], limit=1)
journal_ids = journal_obj.search(
cr, uid,
[('type', '=', 'sale'),
('company_id', '=', contract.company_id.id or False)],
limit=1)
if not journal_ids: if not journal_ids:
raise osv.except_osv(_('Error!'),
_('Please define a sale journal for the company "%s".') % (contract.company_id.name or '', ))
partner_payment_term = contract.partner_id.property_payment_term and contract.partner_id.property_payment_term.id or False
raise osv.except_osv(
_('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 = { inv_data = {
'reference': contract.code or False, 'reference': contract.code or False,
'account_id': contract.partner_id.property_account_receivable.id, 'account_id': contract.partner_id.property_account_receivable.id,
'type': 'out_invoice', 'type': 'out_invoice',
'partner_id': contract.partner_id.id, 'partner_id': contract.partner_id.id,
'currency_id': contract.partner_id.property_product_pricelist.id or False,
'currency_id': contract.partner_id.property_product_pricelist.id,
'journal_id': len(journal_ids) and journal_ids[0] or False, 'journal_id': len(journal_ids) and journal_ids[0] or False,
'date_invoice': contract.recurring_next_date, 'date_invoice': contract.recurring_next_date,
'origin': contract.name, 'origin': contract.name,
@ -160,10 +195,15 @@ class account_analytic_account(osv.osv):
tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes) tax_id = fpos_obj.map_tax(cr, uid, fpos, taxes)
if 'old_date' in context: if 'old_date' in context:
lang_ids = lang_obj.search(cr, uid, [('code', '=', contract.partner_id.lang)], context=context)
format = lang_obj.browse(cr, uid, lang_ids, context=context)[0].date_format
line.name = line.name.replace('#START#', context['old_date'].strftime(format))
line.name = line.name.replace('#END#', context['next_date'].strftime(format))
lang_ids = lang_obj.search(
cr, uid, [('code', '=', contract.partner_id.lang)],
context=context)
format = lang_obj.browse(
cr, uid, lang_ids, context=context)[0].date_format
line.name = line.name.replace(
'#START#', context['old_date'].strftime(format))
line.name = line.name.replace(
'#END#', context['next_date'].strftime(format))
invoice_line_vals = { invoice_line_vals = {
'name': line.name, 'name': line.name,
@ -176,7 +216,8 @@ class account_analytic_account(osv.osv):
'invoice_id': invoice_id, 'invoice_id': invoice_id,
'invoice_line_tax_id': [(6, 0, tax_id)], 'invoice_line_tax_id': [(6, 0, tax_id)],
} }
self.pool.get('account.invoice.line').create(cr, uid, invoice_line_vals, context=context)
self.pool.get('account.invoice.line').create(
cr, uid, invoice_line_vals, context=context)
inv_obj.button_compute(cr, uid, [invoice_id], context=context) inv_obj.button_compute(cr, uid, [invoice_id], context=context)
return invoice_id return invoice_id
@ -185,10 +226,15 @@ class account_analytic_account(osv.osv):
context = context or {} context = context or {}
current_date = time.strftime('%Y-%m-%d') current_date = time.strftime('%Y-%m-%d')
contract_ids = self.search(cr, uid, [('recurring_next_date','<=', current_date), ('state','=', 'open'), ('recurring_invoices','=', True)])
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): 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")
next_date = datetime.datetime.strptime(
contract.recurring_next_date or current_date, "%Y-%m-%d")
interval = contract.recurring_interval interval = contract.recurring_interval
if contract.recurring_rule_type == 'daily': if contract.recurring_rule_type == 'daily':
old_date = next_date-relativedelta(days=+interval) old_date = next_date-relativedelta(days=+interval)
@ -201,9 +247,13 @@ class account_analytic_account(osv.osv):
new_date = next_date+relativedelta(months=+interval) new_date = next_date+relativedelta(months=+interval)
context['old_date'] = old_date context['old_date'] = old_date
context['next_date'] = datetime.datetime.strptime(contract.recurring_next_date or current_date,"%Y-%m-%d")
invoice_id = self._prepare_invoice(cr, uid, contract, context=context)
self.write(cr, uid, [contract.id], {'recurring_next_date': new_date.strftime('%Y-%m-%d')}, context=context)
context['next_date'] = datetime.datetime.strptime(
contract.recurring_next_date or current_date, "%Y-%m-%d")
self._prepare_invoice(
cr, uid, contract, context=context)
self.write(
cr, uid, [contract.id],
{'recurring_next_date': new_date.strftime('%Y-%m-%d')},
context=context)
return True return True

145
contract/i18n/account_analytic_analysis_recurring.pot

@ -0,0 +1,145 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_analytic_analysis_recurring
#
msgid ""
msgstr ""
#. 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"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Day(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,name:0
msgid "Description"
msgstr ""
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:130
#, python-format
msgid "Error!"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoices:0
msgid "Generate recurring invoices automatically"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoice_line_ids:0
msgid "Invoice Lines"
msgstr ""
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_rule_type:0
msgid "Invoice automatically repeat at specified interval"
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!"
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\"."
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,product_id:0
msgid "Product"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,quantity:0
msgid "Quantity"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_rule_type:0
msgid "Recurrency"
msgstr ""
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid "Recurring Invoices"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_interval:0
msgid "Repeat Every"
msgstr ""
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_interval:0
msgid "Repeat every (Days/Week/Month/Year)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_subtotal:0
msgid "Sub Total"
msgstr ""
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_unit:0
msgid "Unit Price"
msgstr ""
#. module: account_analytic_analysis_recurring
#: 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 "Week(s)"
msgstr ""
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Year(s)"
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!"
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"
msgstr ""

156
contract/i18n/nl.po

@ -0,0 +1,156 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_analytic_analysis_recurring
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-07-11 13:24+0000\n"
"PO-Revision-Date: 2014-07-11 13:24+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 ". create invoices"
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid "Account Analytic Lines"
msgstr "Kostenplaatsenboekingen"
#. 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 "Kostenplaats"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_next_date:0
msgid "Date of Next Invoice"
msgstr "Datum volgende factuur"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Day(s)"
msgstr "Dag(en)"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,name:0
msgid "Description"
msgstr "Omschrijving"
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:130
#, python-format
msgid "Error!"
msgstr "Fout"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoices:0
msgid "Generate recurring invoices automatically"
msgstr "Periodieke facturering"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_invoice_line_ids:0
msgid "Invoice Lines"
msgstr "Sjablonen factuurregels"
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_rule_type:0
msgid "Invoice automatically repeat at specified interval"
msgstr "Factureer automatisch met dit interval"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Month(s)"
msgstr "Maand(en)"
#. module: account_analytic_analysis_recurring
#: code:addons/account_analytic_analysis_recurring/account_analytic_analysis_recurring.py:125
#, python-format
msgid "No Customer Defined!"
msgstr "Er is geen klant ingesteld."
#. 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\"."
msgstr "Er moet een inkoopdagboek worden ingesteld voor bedrijf \"%s\"."
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,product_id:0
msgid "Product"
msgstr "Product"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,quantity:0
msgid "Quantity"
msgstr "Hoeveelheid"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_rule_type:0
msgid "Recurrency"
msgstr "Herhaling"
#. module: account_analytic_analysis_recurring
#: view:account.analytic.account:0
msgid "Recurring Invoices"
msgstr "Periodieke facturen"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.account,recurring_interval:0
msgid "Repeat Every"
msgstr "Herhaal elke:"
#. module: account_analytic_analysis_recurring
#: help:account.analytic.account,recurring_interval:0
msgid "Repeat every (Days/Week/Month/Year)"
msgstr "Herhaal elke (dag/week/maand/jaar)"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_subtotal:0
msgid "Sub Total"
msgstr "Subtotaal"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,price_unit:0
msgid "Unit Price"
msgstr "Prijs per eenheid"
#. module: account_analytic_analysis_recurring
#: field:account.analytic.invoice.line,uom_id:0
msgid "Unit of Measure"
msgstr "Maateenheid"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Week(s)"
msgstr "Week/weken"
#. module: account_analytic_analysis_recurring
#: selection:account.analytic.account,recurring_rule_type:0
msgid "Year(s)"
msgstr "Jaar"
#. 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!"
msgstr " Er moet eerst een klant worden ingesteld op contract %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"
Loading…
Cancel
Save