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
1=== modified file 'l10n_mx_invoice_datetime/__openerp__.py'
2--- l10n_mx_invoice_datetime/__openerp__.py 2013-07-16 22:00:59 +0000
3+++ l10n_mx_invoice_datetime/__openerp__.py 2014-06-11 23:16:42 +0000
4@@ -42,7 +42,7 @@
5 ],
6 "demo" : [],
7 "data" : [
8- #"security/dateinvoice_security.xml",
9+ "security/l10n_mx_facturae_security_groups_date.xml",
10 "account_invoice_view.xml"
11 ],
12 "installable" : True,
13
14=== modified file 'l10n_mx_invoice_datetime/account_invoice_view.xml'
15--- l10n_mx_invoice_datetime/account_invoice_view.xml 2013-07-30 16:24:23 +0000
16+++ l10n_mx_invoice_datetime/account_invoice_view.xml 2014-06-11 23:16:42 +0000
17@@ -7,10 +7,10 @@
18 <field name="inherit_id" ref="account.invoice_form"/>
19 <field name="arch" type="xml">
20 <xpath expr="//field[@name='date_invoice']" position="after">
21- <field name="invoice_datetime" groups="l10n_mx_facturae_groups.group_l10n_mx_facturae_manager"/>
22+ <field name="invoice_datetime" groups="l10n_mx_invoice_datetime.group_datetime_invoice_l10n_mx_facturae"/>
23 </xpath>
24 <xpath expr="//field[@name='date_invoice']" position="replace">
25- <field name="date_invoice" groups="l10n_mx_facturae_groups.group_l10n_mx_facturae_user"/>
26+ <field name="date_invoice" groups="l10n_mx_invoice_datetime.group_date_invoice_l10n_mx_facturae"/>
27 </xpath>
28 </field>
29 </record>
30
31=== modified file 'l10n_mx_invoice_datetime/invoice.py'
32--- l10n_mx_invoice_datetime/invoice.py 2013-12-19 16:24:01 +0000
33+++ l10n_mx_invoice_datetime/invoice.py 2014-06-11 23:16:42 +0000
34@@ -158,8 +158,38 @@
35 values['invoice_datetime'],
36 '%Y-%m-%d %H:%M:%S').date().strftime('%Y-%m-%d')
37 if date_invoice != values['date_invoice']:
38- raise osv.except_osv(_('Warning!'),
39- _('Invoice dates should be equal'))
40+ groups_obj = self.pool.get('res.groups')
41+ group_datetime = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'l10n_mx_invoice_datetime', 'group_datetime_invoice_l10n_mx_facturae')
42+ group_date = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'l10n_mx_invoice_datetime', 'group_date_invoice_l10n_mx_facturae')
43+ if group_datetime and group_date:
44+ users_datetime = []
45+ users_date = []
46+ for user in groups_obj.browse(cr, uid, [group_datetime[1]], context=context)[0].users:
47+ users_datetime.append(user.id)
48+ for user in groups_obj.browse(cr, uid, [group_date[1]], context=context)[0].users:
49+ users_date.append(user.id)
50+ if uid in users_datetime:
51+ date_invoice = fields.datetime.context_timestamp(cr, uid,
52+ datetime.datetime.strptime(values['invoice_datetime'],
53+ tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context)
54+ res['date_invoice'] = date_invoice
55+ res['invoice_datetime'] = values['invoice_datetime']
56+ elif uid in users_date:
57+ user_hour = self._get_time_zone(cr, uid, [], context=context)
58+ time_invoice = datetime.time(abs(user_hour), 0, 0)
59+
60+ date_invoice = datetime.datetime.strptime(
61+ values['date_invoice'], '%Y-%m-%d').date()
62+
63+ dt_invoice = datetime.datetime.combine(
64+ date_invoice, time_invoice).strftime('%Y-%m-%d %H:%M:%S')
65+
66+ res['invoice_datetime'] = dt_invoice
67+ res['date_invoice'] = values['date_invoice']
68+ else:
69+ raise osv.except_osv(_('Warning!'), _('Invoice dates should be equal'))
70+ else:
71+ raise osv.except_osv(_('Warning!'), _('Invoice dates should be equal'))
72
73 if not values.get('invoice_datetime', False) and\
74 not values.get('date_invoice', False):
75@@ -170,10 +200,11 @@
76
77 def action_move_create(self, cr, uid, ids, context=None):
78 for inv in self.browse(cr, uid, ids, context=context):
79- vals_date = self.assigned_datetime(cr, uid,
80- {'invoice_datetime': inv.invoice_datetime,
81- 'date_invoice': inv.date_invoice},
82- context=context)
83- self.write(cr, uid, ids, vals_date, context=context)
84+ if inv.type in ('out_invoice', 'out_refund'):
85+ vals_date = self.assigned_datetime(cr, uid,
86+ {'invoice_datetime': inv.invoice_datetime,
87+ 'date_invoice': inv.date_invoice},
88+ context=context)
89+ self.write(cr, uid, ids, vals_date, context=context)
90 return super(account_invoice,
91 self).action_move_create(cr, uid, ids, context=context)
92
93=== added file 'l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml'
94--- l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml 1970-01-01 00:00:00 +0000
95+++ l10n_mx_invoice_datetime/security/l10n_mx_facturae_security_groups_date.xml 2014-06-11 23:16:42 +0000
96@@ -0,0 +1,29 @@
97+<?xml version="1.0" encoding="utf-8"?>
98+<openerp>
99+ <data noupdate="1">
100+
101+ <record model="ir.module.category" id="module_date_invoice_l10n_mx_facturae">
102+ <field name="name">Fecha FacturaE</field>
103+ <field name="description">Indicate tue type of date that need was colocated in the invoice</field>
104+ <field name="sequence">999</field>
105+ </record>
106+
107+ <record id="group_date_invoice_l10n_mx_facturae" model="res.groups">
108+ <field name="name">Date</field>
109+ <field name="comment">Date</field>
110+ <field name="category_id" ref="module_date_invoice_l10n_mx_facturae"/>
111+ </record>
112+
113+ <record id="group_datetime_invoice_l10n_mx_facturae" model="res.groups">
114+ <field name="name">DateTime</field>
115+ <field name="comment">Date Time</field>
116+ <field name="category_id" ref="module_date_invoice_l10n_mx_facturae"/>
117+ <field name="users" eval="[(4, ref('base.user_root'))]"/>
118+ </record>
119+
120+ <record id="group_datetime_invoice_l10n_mx_facturae" model="res.groups">
121+ <field name="implied_ids" eval="[(4, ref('group_datetime_invoice_l10n_mx_facturae'))]"/>
122+ </record>
123+
124+ </data>
125+</openerp>