diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 2643e3b6ee8..d0f38af24f1 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -165,6 +165,7 @@ + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index afc55335099..c4a52b6ceb1 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -111,7 +111,8 @@ class account_invoice(osv.osv): help='The date of the first cash discount'), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}, relate=True), - 'partner_bank_id': fields.many2one('res.partner.bank', 'Partner bank', states={'draft':[('readonly',False)]}), + 'partner_bank_id': fields.many2one('res.partner.bank', 'Partner bank'), + 'bank_id': fields.many2one('res.partner.bank', 'Company bank'), 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}), 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly',False)]}), diff --git a/addons/l10n_ch/__init__.py b/addons/l10n_ch/__init__.py index e09efce7779..a9dbc02a8d8 100755 --- a/addons/l10n_ch/__init__.py +++ b/addons/l10n_ch/__init__.py @@ -30,3 +30,4 @@ import bvr import dta import v11 import partner +import company diff --git a/addons/l10n_ch/__terp__.py b/addons/l10n_ch/__terp__.py index 8e183a8e020..e79ecead756 100755 --- a/addons/l10n_ch/__terp__.py +++ b/addons/l10n_ch/__terp__.py @@ -16,7 +16,8 @@ "v11/v11_wizard.xml","v11/v11_view.xml", "account_vat.xml","base_config.xml","account_config.xml", "bvr/bvr_report.xml", - #"company_view.xml", + "bvr/bvr_wizard.xml", + "company_view.xml", #"partner_view.xml", ], "active": False, diff --git a/addons/l10n_ch/bvr/bvr_wizard.xml b/addons/l10n_ch/bvr/bvr_wizard.xml new file mode 100644 index 00000000000..7966fd2dc06 --- /dev/null +++ b/addons/l10n_ch/bvr/bvr_wizard.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/addons/l10n_ch/bvr/report/bvr.py b/addons/l10n_ch/bvr/report/bvr.py index c0556159106..1ae1c326d67 100644 --- a/addons/l10n_ch/bvr/report/bvr.py +++ b/addons/l10n_ch/bvr/report/bvr.py @@ -31,13 +31,28 @@ from report import report_sxw class account_invoice_bvr(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(account_invoice_bvr, self).__init__(cr, uid, name, context) - raise 'a' self.localcontext.update({ 'time': time, 'user':self.pool.get("res.users").browse(cr,uid,uid), 'mod10r': self._mod10r, + '_space': self._space, + '_get_ref': self._get_ref, }) + def _space(self,nbr, nbrspc=5): + res = '' + for i in range(len(nbr)): + res = res + nbr[i] + if not (i-1) % nbrspc: + res = res + ' ' + return res + + def _get_ref(self, o): + res = '' + if o.bank_id.bank_code: + res = o.bank_id.bank_code + return self._mod10r(res+o.number.rjust(26-len(res), '0')) + def _mod10r(self,nbr): """ Input arg : account or invoice number diff --git a/addons/l10n_ch/bvr/report/bvr.rml b/addons/l10n_ch/bvr/report/bvr.rml index 5531b8f09b6..f0049463e73 100644 --- a/addons/l10n_ch/bvr/report/bvr.rml +++ b/addons/l10n_ch/bvr/report/bvr.rml @@ -115,10 +115,10 @@ --> - [[ user.company_id.partner_id.name ]] - [[ user.company_id.partner_id.address[0].street ]] - [[ (user.company_id.partner_id.address[0].street2 or '')]] - [[ user.company_id.partner_id.address[0].zip ]] [[ user.company_id.partner_id.address[0].city ]] + [[ user.company_id.partner_id.name ]] + [[ user.company_id.partner_id.address[0].street ]] + [[ (user.company_id.partner_id.address[0].street2 or '')]] + [[ user.company_id.partner_id.address[0].zip ]] [[ user.company_id.partner_id.address[0].city ]] [[ user.company_id.partner_id.name ]] [[ user.company_id.partner_id.address[0].street ]] @@ -127,20 +127,22 @@ - [[ o.partner_id.name ]] - [[ o.address_invoice_id.street ]] - [[ (o.address_invoice_id.street2 or '')]] - [[ o.address_invoice_id.zip ]] [[ o.address_invoice_id.city ]] + [[ o.partner_id.name ]] + [[ o.address_invoice_id.street ]] + [[ (o.address_invoice_id.street2 or '')]] + [[ o.address_invoice_id.zip ]] [[ o.address_invoice_id.city ]] - [[ mod10r(o.number).rjust(27,'0')]] + [[ _get_ref(o) ]] [[ o.partner_id.name ]] [[ o.address_invoice_id.street ]] [[ (o.address_invoice_id.street2 or '')]] [[ o.address_invoice_id.zip ]] [[ o.address_invoice_id.city ]] + + [[ _space(_get_ref(o)) ]] + - [[ mod10r(o.number).rjust(27,'0') ]] [[ ('%.2f' % o.amount_total)[:-3] ]] [[ ('%.2f' % o.amount_total)[:-3] ]] @@ -154,104 +156,10 @@ --> - 01[[mod10r('%.2f' % o.amount_total).rjust(11,'0')]]>[[ mod10r(o.number).rjust(27,'0')]]+ [[o.partner_bank_id.bvr_number.split('-')[0]+(o.partner_bank_id.bvr_number.split('-')[1]).rjust(6,'0')+o.partner_bank_id.bvr_number.split('-')[2] ]]> - + + 01[[mod10r('%.2f' % o.amount_total).rjust(11,'0')]]>[[ _get_ref(o) ]]+ [[o.bank_id.bvr_number.split('-')[0]+(o.bank_id.bvr_number.split('-')[1]).rjust(6,'0')+o.bank_id.bvr_number.split('-')[2] ]]> - diff --git a/addons/l10n_ch/bvr/wizard/wizard_bvr.py b/addons/l10n_ch/bvr/wizard/wizard_bvr.py index cc39f8c8f32..88bf9c0c2b4 100644 --- a/addons/l10n_ch/bvr/wizard/wizard_bvr.py +++ b/addons/l10n_ch/bvr/wizard/wizard_bvr.py @@ -26,10 +26,16 @@ ############################################################################## import wizard +import pooler +import re def _check(self, cr, uid, data, context): - for invoice in self.pool.get('account.invoice').browse(cr, uid, data['ids'], context): - pass + for invoice in pooler.get_pool(cr.dbname).get('account.invoice').browse(cr, uid, data['ids'], context): + if not invoice.bank_id: + raise wizard.except_wizard('UserError','The invoice "%s" has no bank associated !' % (invoice.number,)) + if not re.compile('[0-9][0-9]?\-[0-9]+-[0-9]+').match(invoice.bank_id.bvr_number or ''): + raise wizard.except_wizard('UserError','Your bank BVR number should be of the form 0X-XXX-X !\nSee invoice "%s".' % (invoice.number,)) + return {} class wizard_report(wizard.interface): diff --git a/addons/l10n_ch/company.py b/addons/l10n_ch/company.py index 936b62f9832..66531b01bdb 100644 --- a/addons/l10n_ch/company.py +++ b/addons/l10n_ch/company.py @@ -34,10 +34,8 @@ from osv import fields, osv class res_company(osv.osv): _inherit = "res.company" _columns = { - 'bvr_number': fields.char('BVR Number', size=9), 'bvr_delta_horz': fields.float('BVR Horz. Delta (mm)', size=(16,2)), 'bvr_delta_vert': fields.float('BVR Vert. Delta (mm)', size=(16,2)), - 'dta_number': fields.char('DTA Number', size=9), } res_company() diff --git a/addons/l10n_ch/company_view.xml b/addons/l10n_ch/company_view.xml index 4ddc13ef7dd..3e225405efc 100644 --- a/addons/l10n_ch/company_view.xml +++ b/addons/l10n_ch/company_view.xml @@ -8,10 +8,8 @@ - - diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 4e0e348ce4b..a034460088c 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -98,7 +98,7 @@ class purchase_order(osv.osv): 'pricelist_id':fields.many2one('product.pricelist', 'Pricelist', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), - 'state': fields.selection([('draft', 'Request for Quotation'), ('wait', 'Waiting'), ('confirmed', 'Confirmed'), ('approved', 'Approved'),('except_ship', 'Shipping Exception'), ('except_invoice', 'Invoice Exception'), ('done', 'Done'), ('cancel', 'Cancelled')], 'Order State', readonly=True, help="The state of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' state. Then the order has to be confirmed by the user, the state switch to 'Confirmed'. Then the supplier must confirm the order to change the state to 'Approved'. When the purchase order is paid and received, the state becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the state becomes in exception.", select=True), + 'state': fields.selection([('draft', 'Request for Quotation'), ('wait', 'Waiting'), ('confirmed', 'Confirmed'), ('approved', 'Approved'),('except_picking', 'Shipping Exception'), ('except_invoice', 'Invoice Exception'), ('done', 'Done'), ('cancel', 'Cancelled')], 'Order State', readonly=True, help="The state of the purchase order or the quotation request. A quotation is a purchase order in a 'Draft' state. Then the order has to be confirmed by the user, the state switch to 'Confirmed'. Then the supplier must confirm the order to change the state to 'Approved'. When the purchase order is paid and received, the state becomes 'Done'. If a cancel action occurs in the invoice or in the reception of goods, the state becomes in exception.", select=True), 'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order State', states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}), 'validator' : fields.many2one('res.users', 'Validated by', readonly=True), 'notes': fields.text('Notes'),