Skip to content

Commit

Permalink
Merge pull request Vauxoo#33 from vauxoo-dev/8.0-FIX-duplicated-dev-s…
Browse files Browse the repository at this point in the history
…uniagajose

[IMP] Basic migration OVL 7.0 to 8.0
  • Loading branch information
moylop260 committed Dec 17, 2015
2 parents dbe9da2 + b4d46fc commit 185773c
Show file tree
Hide file tree
Showing 68 changed files with 2,221 additions and 3,607 deletions.
37 changes: 18 additions & 19 deletions l10n_ve_fiscal_book/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,13 @@ def _get_doc(self, cr, uid, ids, name, args, context=None):
ret.update({i: ''})
if invs:
for inv in invs:
if ((inv.type == "in_invoice" or inv.type == "out_invoice")
and inv.parent_id):
if inv.type in ['in_invoice', 'out_invoice'] and inv.parent_id:
doc_type = "ND"
elif ((inv.type == "in_invoice" or inv.type == "in_refund")
and inv.expedient):
elif inv.type in ['in_invoice', 'in_refund'] and inv.expedient:
doc_type = "E"
elif inv.type == 'in_refund' or inv.type == 'out_refund':
elif inv.type in ['in_refund', 'out_refund']:
doc_type = "NC"
elif inv.type == "in_invoice" or inv.type == "out_invoice":
elif inv.type in ['in_invoice', 'out_invoice']:
doc_type = "F"
ret.update({inv.id: doc_type})
return ret
Expand All @@ -206,11 +204,11 @@ def _get_t_doc(self, cr, uid, ids, name, args, context=None):
ret.update({i: ''})
if invs:
for inv in invs:
if ((inv.type == "in_invoice" or inv.type == "out_invoice")
and inv.parent_id):
if (inv.type == "in_invoice" or
inv.type == "out_invoice") and inv.parent_id:
doc_type = "N/DE"
elif ((inv.type == "in_invoice" or inv.type == "in_refund")
and inv.expedient):
elif (inv.type == "in_invoice" or
inv.type == "in_refund") and inv.expedient:
doc_type = "E"
elif inv.type == 'in_refund' or inv.type == 'out_refund':
doc_type = "N/CR"
Expand Down Expand Up @@ -299,11 +297,11 @@ def _get_taxes(self, cr, uid, ids, name, args, context=None):
data = tax_obj.browse(cr, uid, tax_ids)

for tax in data:
if ('SDCF' in tax.name and tax.tax_id.amount == 0.00
and tam >= 2):
if 'SDCF' in tax.name and tax.tax_id.amount == 0.00 and \
tam >= 2:
tax_ids.remove(tax.id)
elif ('EXENTO' in tax.name and tax.tax_id.amount == 0.00
and tam >= 2):
elif 'EXENTO' in tax.name and tax.tax_id.amount == 0.00 and \
tam >= 2:
tax_ids.remove(tax.id)
elif tax.tax_id.amount == 0.00 and tam >= 2:
tax_ids.remove(tax.id)
Expand Down Expand Up @@ -390,9 +388,10 @@ def _get_debit_affected(self, cr, uid, ids, name, args, context=None):
res = self.browse(cr, uid, ids)
ret = {}
for inv_brw in res:
if (inv_brw.parent_id and
inv_brw.parent_id.type in ['in_invoice', 'out_invoice']
and inv_brw.parent_id.parent_id):
if inv_brw.parent_id and \
inv_brw.parent_id.type in \
['in_invoice', 'out_invoice'] and \
inv_brw.parent_id.parent_id:
ret.update({inv_brw.id: inv_brw.parent_id.number})
else:
ret.update({inv_brw.id: ''})
Expand All @@ -405,8 +404,8 @@ def _get_credit_affected(self, cr, uid, ids, name, args, context=None):
res = self.browse(cr, uid, ids)
ret = {}
for inv_brw in res:
if (inv_brw.parent_id
and inv_brw.parent_id.type in ['in_refund', 'out_refund']):
if inv_brw.parent_id and \
inv_brw.parent_id.type in ['in_refund', 'out_refund']:
ret.update({inv_brw.id: inv_brw.parent_id.number})
else:
ret.update({inv_brw.id: ''})
Expand Down
126 changes: 69 additions & 57 deletions l10n_ve_fiscal_book/model/fiscal_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def _get_total_with_iva_sum(self, cr, uid, ids, field_names, arg,
if fbl_brw.invoice_id or fbl_brw.cf_id:
fbl_op_type = fbl_brw.type in ['im', 'ex'] and 'imex' \
or fbl_brw.type
res[fb_brw.id]["get_total_with_iva_" + fbl_op_type + "_sum"] += \
fbl_brw.total_with_iva
fbl_index = "get_total_with_iva_" + fbl_op_type + "_sum"
res[fb_brw.id][fbl_index] += fbl_brw.total_with_iva

res[fb_brw.id]['get_total_with_iva_sum'] = \
sum([res[fb_brw.id]["get_total_with_iva_" + optype + "_sum"]
Expand Down Expand Up @@ -200,6 +200,10 @@ def _get_do_adjustment_vat_tax_sum(self, cr, uid, ids, field_name, arg,
res[fb_brw.id] = avts
return res

def _get_company(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context)
return user.company_id.id

_description = "Venezuela's Sale & Purchase Fiscal Books"
_name = 'fiscal.book'
_inherit = ['mail.thread']
Expand All @@ -215,19 +219,20 @@ def _get_do_adjustment_vat_tax_sum(self, cr, uid, ids, field_name, arg,
" regular periods, i.e. not opening/closing periods."),
'fortnight': fields.selection(
[('first', "First Fortnight"), ('second', "Second Fortnight")],
string="Fortnight",
string="Fortnight", default=None,
help="Fortnight that applies to the current book."),
'state': fields.selection([('draft', 'Getting Ready'),
('confirmed', 'Approved by Manager'),
('done', 'Seniat Submitted'),
('cancel', 'Cancel')],
string='Status', required=True,
readonly=True),
readonly=True, default='draft'),
'type': fields.selection([('sale', 'Sale Book'),
('purchase', 'Purchase Book')],
help="Select Sale for Customers and"
" Purchase for Suppliers",
string='Book Type', required=True),
string='Book Type', required=True,
default=lambda s: s._get_type()),
'base_amount': fields.float('Taxable Amount',
help='Amount used as Taxing Base'),
'tax_amount': fields.float('Taxed Amount',
Expand Down Expand Up @@ -261,6 +266,7 @@ def _get_do_adjustment_vat_tax_sum(self, cr, uid, ids, field_name, arg,
_get_article_number_types,
string="Article Number",
required=True,
default=lambda s: s._get_article_number(),
help="Article number describing the fiscal book special features"
" according to the Venezuelan RLIVA statement for fiscal"
" accounting books. Options:"
Expand Down Expand Up @@ -584,15 +590,6 @@ def _get_do_adjustment_vat_tax_sum(self, cr, uid, ids, field_name, arg,
" Sum of Reduced VAT Tax column for Non-Tax Payer transactions"),
}

_defaults = {
'state': 'draft',
'type': _get_type,
'company_id': lambda s, c, u, ctx:
s.pool.get('res.users').browse(c, u, u, context=ctx).company_id.id,
'article_number': _get_article_number,
'fortnight': None,
}

_sql_constraints = [
('period_type_company_uniq',
'unique (period_id,type,company_id,fortnight)',
Expand Down Expand Up @@ -997,20 +994,22 @@ def update_book_lines(self, cr, uid, fb_id, context=None):
'type': t_type,
'accounting_date': iwdl_brw.date_ret or False,
'emission_date':
iwdl_brw.date or iwdl_brw.date_ret or False,
iwdl_brw.date or iwdl_brw.date_ret or False,
'doc_type': self.get_doc_type(cr, uid, iwdl_id=iwdl_brw.id,
fb_id=fb_id,
context=context),
'wh_number': iwdl_brw.retention_id.number or False,
'partner_name': rp_brw.name or 'N/A',
'partner_vat': rp_brw.vat or 'N/A',
'affected_invoice': iwdl_brw.invoice_id.fiscal_printer
and iwdl_brw.invoice_id.invoice_printer
or (fb_brw.type == 'sale'
and iwdl_brw.invoice_id.number
or iwdl_brw.invoice_id.supplier_invoice_number),
'affected_invoice_date': iwdl_brw.invoice_id.date_document
or iwdl_brw.invoice_id.date_invoice,
'affected_invoice':
iwdl_brw.invoice_id.fiscal_printer and
iwdl_brw.invoice_id.invoice_printer or
(fb_brw.type == 'sale' and
iwdl_brw.invoice_id.number or
iwdl_brw.invoice_id.supplier_invoice_number),
'affected_invoice_date':
iwdl_brw.invoice_id.date_document or
iwdl_brw.invoice_id.date_invoice,
'wh_rate': iwdl_brw.wh_iva_rate,
}
data.append((0, 0, values))
Expand All @@ -1033,42 +1032,57 @@ def update_book_lines(self, cr, uid, fb_id, context=None):
values = {
'invoice_id': inv_brw.id,
'emission_date':
(not imex_invoice) and
(inv_brw.date_document or inv_brw.date_invoice) or False,
(not imex_invoice) and
(inv_brw.date_document or inv_brw.date_invoice) or
False,
'accounting_date':
(not imex_invoice) and inv_brw.date_invoice or False,
(not imex_invoice) and
inv_brw.date_invoice or
False,
'imex_date':
imex_invoice and inv_brw.customs_form_id.date_liq or False,
'type': self.get_transaction_type(cr, uid, fb_id, inv_brw.id,
context=context),
imex_invoice and
inv_brw.customs_form_id.date_liq or
False,
'type': self.get_transaction_type(
cr, uid, fb_id, inv_brw.id, context=context),
'debit_affected':
inv_brw.parent_id
and inv_brw.parent_id.type in ['in_invoice', 'out_invoice']
and inv_brw.parent_id.parent_id
and inv_brw.parent_id.number or False,
inv_brw.parent_id and
inv_brw.parent_id.type in
['in_invoice', 'out_invoice'] and
inv_brw.parent_id.parent_id and
inv_brw.parent_id.number or
False,
'credit_affected':
inv_brw.parent_id and
inv_brw.parent_id.type in ['in_refund', 'out_refund']
and inv_brw.parent_id.number or False,
inv_brw.parent_id and
inv_brw.parent_id.type in
['in_refund', 'out_refund'] and
inv_brw.parent_id.number or
False,
'ctrl_number':
not inv_brw.fiscal_printer and inv_brw.nro_ctrl or False,
not inv_brw.fiscal_printer and
inv_brw.nro_ctrl or
False,
'affected_invoice':
(doc_type == "N/DE" or doc_type == "N/CR")
and (inv_brw.parent_id and inv_brw.parent_id.number or False)
or False,
(doc_type == "N/DE" or doc_type == "N/CR") and (
inv_brw.parent_id and
inv_brw.parent_id.number or
False) or
False,
'partner_name': rp_brw.name or 'N/A',
'partner_vat': rp_brw.vat
and rp_brw.vat[2:] or 'N/A',
'invoice_number': inv_brw.fiscal_printer
and inv_brw.invoice_printer
or (fb_brw.type == 'sale'
and inv_brw.number
or inv_brw.supplier_invoice_number),
'partner_vat': rp_brw.vat and rp_brw.vat[2:] or 'N/A',
'invoice_number':
inv_brw.fiscal_printer and
inv_brw.invoice_printer or(
fb_brw.type == 'sale' and
inv_brw.number or
inv_brw.supplier_invoice_number),
'doc_type': doc_type,
'void_form': inv_brw.name and
(inv_brw.name.find('PAPELANULADO') >= 0
and '03-ANU' or '01-REG')
or '01-REG',
'void_form':
inv_brw.name and (
inv_brw.name.find('PAPELANULADO') >= 0 and
'03-ANU' or
'01-REG') or
'01-REG',
'fiscal_printer': inv_brw.fiscal_printer or False,
'z_report': inv_brw.z_report or False,
'custom_statement': inv_brw.customs_form_id.name or False,
Expand Down Expand Up @@ -1132,8 +1146,8 @@ def get_cfl_sum(self, cr, uid, cf_id, partner_id, context=None):
cfl_brws = cf_obj.browse(cr, uid, cf_id, context=context).cfl_ids
amount = sum([cfl_brw.amount
for cfl_brw in cfl_brws
if cfl_brw.tax_code.partner_id.id == partner_id
and not cfl_brw.tax_code.vat_detail])
if cfl_brw.tax_code.partner_id.id == partner_id and
not cfl_brw.tax_code.vat_detail])
return amount

def get_grouped_consecutive_lines_ids(self, cr, uid, lines_ids,
Expand Down Expand Up @@ -1966,7 +1980,9 @@ def _compute_vat_rates(self, cr, uid, ids, field_name, arg, context=None):
help="Non-Tax Payer Group of book lines that this line represent"),

# Invoice and/or Document Data
'rank': fields.integer("Line", required=True, help="Line Position"),
'rank': fields.integer(
"Line", required=True, default=0,
help="Line Position"),
'emission_date': fields.date(
string='Emission Date',
help='Invoice Document Date / Wh IVA Line Voucher Date'),
Expand Down Expand Up @@ -2070,10 +2086,6 @@ def _compute_vat_rates(self, cr, uid, ids, field_name, arg, context=None):
help="Vat plus additional tax rate "),
}

_defaults = {
'rank': 0,
}


class FiscalBookTaxes(orm.Model):

Expand Down
19 changes: 10 additions & 9 deletions l10n_ve_fiscal_book/model/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################
from openerp import api
from openerp.osv import fields, osv
from openerp.tools.translate import _

Expand All @@ -47,7 +48,7 @@ def action_cancel(self, cr, uid, ids, context=None):
if (not inv_brw.fb_id or
(inv_brw.fb_id and inv_brw.fb_id.state == 'cancel')):
super(AccountInvoice, self).action_cancel(cr, uid, ids,
context=context)
context=context)
else:
raise osv.except_osv(
_("Error!"),
Expand All @@ -58,7 +59,8 @@ def action_cancel(self, cr, uid, ids, context=None):
inv_brw.fb_id.state,)))
return True

def copy(self, cur, uid, ids, default=None, context=None):
@api.multi
def copy(self, default=None):
"""
Overwrite the copy orm method to blank the fiscal book field when
a invoice is copy. Also if a invoice have benn remove from a fiscal
Expand All @@ -67,11 +69,10 @@ def copy(self, cur, uid, ids, default=None, context=None):
"""
# NOTE: Use as parameter 'ids' instead of 'id' for fix pylint W0622
# Redefining built-in 'id'.
context = context or {}
default = default or {}
default.update(fb_id=False)
if default is None:
default = {}
default = default.copy()
default.update({'fb_id': False})
if default.get('issue_fb_id', False):
default.update(issue_fb_id=False)
res = super(AccountInvoice, self).copy(
cur, uid, ids, default=default, context=context)
return res
default.update({'issue_fb_id': False})
return super(AccountInvoice, self).copy(default)
9 changes: 4 additions & 5 deletions l10n_ve_fiscal_book/wizard/change_invoice_sin_cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ class ChangeInvoiceSinCredwizard(osv.TransientModel):
_name = 'change.invoice.sin.cred'
_description = 'Change Invoice Tax Exempt'
_columns = {
'sin_cred': fields.boolean('Tax Exempt', help='Tax Exempt'),
'sin_cred': fields.boolean(
'Tax Exempt',
default=lambda s: s._context.get('invoice_sin_cred'),
help='Tax Exempt'),
'sure': fields.boolean('Are you sure?'),
}

_defaults = {
'sin_cred': lambda s, cr, u, ctx: ctx.get('invoice_sin_cred', False),
}

def set_sin_cred(self, cr, uid, ids, context=None):
"""
Change the sin cred field in the invoice
Expand Down
14 changes: 5 additions & 9 deletions l10n_ve_fiscal_book/wizard/fiscal_book_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def default_get(self, cr, uid, field_list, context=None):
cr, uid, [('id', '=', context['active_id'])])
fiscal_book_o = fiscal_book_obj.browse(cr, uid, fiscal_book_o[0])
res = super(FiscalBookWizard, self).default_get(cr, uid, field_list,
context=context)
context=context)
res.update({'type': fiscal_book_o.type})
res.update({'date_start':
fiscal_book_o.period_id and
Expand Down Expand Up @@ -203,8 +203,10 @@ def _print_report(self, cr, uid, ids, data, context=None):
'report_name': 'fiscal.book.purchase', 'datas': data}

_columns = {
"date_start": fields.date("Start Date", required=True),
"date_end": fields.date("End Date", required=True),
"date_start": fields.date("Start Date", required=True,
default=time.strftime('%Y-%m-%d')),
"date_end": fields.date("End Date", required=True,
default=time.strftime('%Y-%m-%d')),
"control_start": fields.integer("Control Start"),
"control_end": fields.integer("Control End"),
"type": fields.selection([
Expand All @@ -214,10 +216,4 @@ def _print_report(self, cr, uid, ids, data, context=None):
),
}

_defaults = {
'date_start': lambda *a: time.strftime('%Y-%m-%d'),
'date_end': lambda *a: time.strftime('%Y-%m-%d'),
# 'type': lambda *a: 'sale',
}

FiscalBookWizard()
Loading

0 comments on commit 185773c

Please sign in to comment.