Merge lp:~vauxoo/openerp-mexico-localization/7.0-dateinvoice-dev_luis into lp:openerp-mexico-localization/7.0

Proposed by Luis Torres - http://www.vauxoo.com
Status: Merged
Merged at revision: 375
Proposed branch: lp:~vauxoo/openerp-mexico-localization/7.0-dateinvoice-dev_luis
Merge into: lp:openerp-mexico-localization/7.0
Diff against target: 125 lines (+70/-10)
4 files modified
l10n_mx_invoice_datetime/__openerp__.py (+1/-1)
l10n_mx_invoice_datetime/account_invoice_view.xml (+2/-2)
l10n_mx_invoice_datetime/invoice.py (+38/-7)
l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml (+29/-0)
To merge this branch: bzr merge lp:~vauxoo/openerp-mexico-localization/7.0-dateinvoice-dev_luis
Reviewer Review Type Date Requested Status
Moisés López - http://www.vauxoo.com Approve
Luis Torres - http://www.vauxoo.com (community) Needs Resubmitting
Julio Serna-http://www.vauxoo.com Pending
Review via email: mp+218887@code.launchpad.net

Description of the change

Se agrego un grupo para indicar si en la factura se mostrará la fecha de tipo date o de tipo datetime

To post a comment you must log in.
371. By Luis Torres - http://www.vauxoo.com

[FIX][l10n_mx_invoice_datetime]Was added validation that the field invoice_datetime only fill in customer invoices

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se agrego que campo invoice_datetime unicamente se llene para las facturas de cliente, en las de proveedor se realiza el comportamiento de openerp para las facturas

review: Needs Resubmitting
372. By Luis Torres - http://www.vauxoo.com

[FIX][l10n_mx_invoice_datetime]Resolved that when the invoice have date_invoice and invoice_datetime, depends of the group of the user if this not were equals, this was updated according the group

373. By Luis Torres - http://www.vauxoo.com

[FIX][l10n_mx_invoice_datetime]Resolved that not implied group datetime to group date

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se agrego validación para que cuando la factura tenga date y datetime, revise a que grupo pertenece, y en caso de que sean diferentes se actualice una a otra, de acuerdo a la causistica del grupo.

Se corrigio que cuando se seleccione el grupo date no muestre datetime en la factura

review: Needs Resubmitting
374. By Luis Torres - http://www.vauxoo.com

[IMP][l10n_mx_invoice_datetime]Was changed the search by name product by xml_id

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se cambio en el search para que en lugar de buscar por nombre del grupo lo busque por xml_id

review: Needs Resubmitting
Revision history for this message
Moisés López - http://www.vauxoo.com (moylop260) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_mx_invoice_datetime/__openerp__.py'
--- l10n_mx_invoice_datetime/__openerp__.py 2013-07-16 22:00:59 +0000
+++ l10n_mx_invoice_datetime/__openerp__.py 2014-06-11 23:16:42 +0000
@@ -42,7 +42,7 @@
42 ],42 ],
43 "demo" : [],43 "demo" : [],
44 "data" : [44 "data" : [
45 #"security/dateinvoice_security.xml",45 "security/l10n_mx_facturae_security_groups_date.xml",
46 "account_invoice_view.xml"46 "account_invoice_view.xml"
47 ],47 ],
48 "installable" : True,48 "installable" : True,
4949
=== modified file 'l10n_mx_invoice_datetime/account_invoice_view.xml'
--- l10n_mx_invoice_datetime/account_invoice_view.xml 2013-07-30 16:24:23 +0000
+++ l10n_mx_invoice_datetime/account_invoice_view.xml 2014-06-11 23:16:42 +0000
@@ -7,10 +7,10 @@
7 <field name="inherit_id" ref="account.invoice_form"/>7 <field name="inherit_id" ref="account.invoice_form"/>
8 <field name="arch" type="xml">8 <field name="arch" type="xml">
9 <xpath expr="//field[@name='date_invoice']" position="after">9 <xpath expr="//field[@name='date_invoice']" position="after">
10 <field name="invoice_datetime" groups="l10n_mx_facturae_groups.group_l10n_mx_facturae_manager"/>10 <field name="invoice_datetime" groups="l10n_mx_invoice_datetime.group_datetime_invoice_l10n_mx_facturae"/>
11 </xpath>11 </xpath>
12 <xpath expr="//field[@name='date_invoice']" position="replace">12 <xpath expr="//field[@name='date_invoice']" position="replace">
13 <field name="date_invoice" groups="l10n_mx_facturae_groups.group_l10n_mx_facturae_user"/>13 <field name="date_invoice" groups="l10n_mx_invoice_datetime.group_date_invoice_l10n_mx_facturae"/>
14 </xpath>14 </xpath>
15 </field>15 </field>
16 </record>16 </record>
1717
=== modified file 'l10n_mx_invoice_datetime/invoice.py'
--- l10n_mx_invoice_datetime/invoice.py 2013-12-19 16:24:01 +0000
+++ l10n_mx_invoice_datetime/invoice.py 2014-06-11 23:16:42 +0000
@@ -158,8 +158,38 @@
158 values['invoice_datetime'],158 values['invoice_datetime'],
159 '%Y-%m-%d %H:%M:%S').date().strftime('%Y-%m-%d')159 '%Y-%m-%d %H:%M:%S').date().strftime('%Y-%m-%d')
160 if date_invoice != values['date_invoice']:160 if date_invoice != values['date_invoice']:
161 raise osv.except_osv(_('Warning!'),161 groups_obj = self.pool.get('res.groups')
162 _('Invoice dates should be equal'))162 group_datetime = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'l10n_mx_invoice_datetime', 'group_datetime_invoice_l10n_mx_facturae')
163 group_date = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'l10n_mx_invoice_datetime', 'group_date_invoice_l10n_mx_facturae')
164 if group_datetime and group_date:
165 users_datetime = []
166 users_date = []
167 for user in groups_obj.browse(cr, uid, [group_datetime[1]], context=context)[0].users:
168 users_datetime.append(user.id)
169 for user in groups_obj.browse(cr, uid, [group_date[1]], context=context)[0].users:
170 users_date.append(user.id)
171 if uid in users_datetime:
172 date_invoice = fields.datetime.context_timestamp(cr, uid,
173 datetime.datetime.strptime(values['invoice_datetime'],
174 tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)
175 res['date_invoice'] = date_invoice
176 res['invoice_datetime'] = values['invoice_datetime']
177 elif uid in users_date:
178 user_hour = self._get_time_zone(cr, uid, [], context=context)
179 time_invoice = datetime.time(abs(user_hour), 0, 0)
180
181 date_invoice = datetime.datetime.strptime(
182 values['date_invoice'], '%Y-%m-%d').date()
183
184 dt_invoice = datetime.datetime.combine(
185 date_invoice, time_invoice).strftime('%Y-%m-%d %H:%M:%S')
186
187 res['invoice_datetime'] = dt_invoice
188 res['date_invoice'] = values['date_invoice']
189 else:
190 raise osv.except_osv(_('Warning!'), _('Invoice dates should be equal'))
191 else:
192 raise osv.except_osv(_('Warning!'), _('Invoice dates should be equal'))
163 193
164 if not values.get('invoice_datetime', False) and\194 if not values.get('invoice_datetime', False) and\
165 not values.get('date_invoice', False):195 not values.get('date_invoice', False):
@@ -170,10 +200,11 @@
170200
171 def action_move_create(self, cr, uid, ids, context=None):201 def action_move_create(self, cr, uid, ids, context=None):
172 for inv in self.browse(cr, uid, ids, context=context):202 for inv in self.browse(cr, uid, ids, context=context):
173 vals_date = self.assigned_datetime(cr, uid,203 if inv.type in ('out_invoice', 'out_refund'):
174 {'invoice_datetime': inv.invoice_datetime,204 vals_date = self.assigned_datetime(cr, uid,
175 'date_invoice': inv.date_invoice},205 {'invoice_datetime': inv.invoice_datetime,
176 context=context)206 'date_invoice': inv.date_invoice},
177 self.write(cr, uid, ids, vals_date, context=context)207 context=context)
208 self.write(cr, uid, ids, vals_date, context=context)
178 return super(account_invoice,209 return super(account_invoice,
179 self).action_move_create(cr, uid, ids, context=context)210 self).action_move_create(cr, uid, ids, context=context)
180211
=== added file 'l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml'
--- l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml 1970-01-01 00:00:00 +0000
+++ l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml 2014-06-11 23:16:42 +0000
@@ -0,0 +1,29 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data noupdate="1">
4
5 <record model="ir.module.category" id="module_date_invoice_l10n_mx_facturae">
6 <field name="name">Fecha FacturaE</field>
7 <field name="description">Indicate tue type of date that need was colocated in the invoice</field>
8 <field name="sequence">999</field>
9 </record>
10
11 <record id="group_date_invoice_l10n_mx_facturae" model="res.groups">
12 <field name="name">Date</field>
13 <field name="comment">Date</field>
14 <field name="category_id" ref="module_date_invoice_l10n_mx_facturae"/>
15 </record>
16
17 <record id="group_datetime_invoice_l10n_mx_facturae" model="res.groups">
18 <field name="name">DateTime</field>
19 <field name="comment">Date Time</field>
20 <field name="category_id" ref="module_date_invoice_l10n_mx_facturae"/>
21 <field name="users" eval="[(4, ref('base.user_root'))]"/>
22 </record>
23
24 <record id="group_datetime_invoice_l10n_mx_facturae" model="res.groups">
25 <field name="implied_ids" eval="[(4, ref('group_datetime_invoice_l10n_mx_facturae'))]"/>
26 </record>
27
28 </data>
29</openerp>