-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 39a490e
Showing
27 changed files
with
2,207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
import controllers | ||
import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
{ | ||
'name': "ncf_manager", | ||
|
||
'summary': """ | ||
Short (1 phrase/line) summary of the module's purpose, used as | ||
subtitle on modules listing or apps.openerp.com""", | ||
|
||
'description': """ | ||
Long description of module's purpose | ||
""", | ||
|
||
'author': "My Company", | ||
'website': "http://www.yourcompany.com", | ||
|
||
# Categories can be used to filter modules in modules listing | ||
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml | ||
# for the full list | ||
'category': 'Uncategorized', | ||
'version': '0.1', | ||
|
||
# any module necessary for this one to work correctly | ||
'depends': ['base','account'], | ||
|
||
# always loaded | ||
'data': [ | ||
# 'security/ir.model.access.csv', | ||
'templates.xml', | ||
'views/partner_view.xml', | ||
'views/shop_view.xml', | ||
'views/account_view.xml', | ||
'views/account_invoice_view.xml', | ||
'views/dgii_purchase_view.xml', | ||
'views/dgii_sale_view.xml', | ||
'views/dgii_cancel_view.xml', | ||
'views/dgii_exterior_view.xml', | ||
'views/account_invoice_state_view.xml' | ||
], | ||
# only loaded in demonstration mode | ||
'demo': [ | ||
'demo.xml', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
from openerp import http | ||
|
||
# class NcfManager(http.Controller): | ||
# @http.route('/ncf_manager/ncf_manager/', auth='public') | ||
# def index(self, **kw): | ||
# return "Hello, world" | ||
|
||
# @http.route('/ncf_manager/ncf_manager/objects/', auth='public') | ||
# def list(self, **kw): | ||
# return http.request.render('ncf_manager.listing', { | ||
# 'root': '/ncf_manager/ncf_manager', | ||
# 'objects': http.request.env['ncf_manager.ncf_manager'].search([]), | ||
# }) | ||
|
||
# @http.route('/ncf_manager/ncf_manager/objects/<model("ncf_manager.ncf_manager"):obj>/', auth='public') | ||
# def object(self, obj, **kw): | ||
# return http.request.render('ncf_manager.object', { | ||
# 'object': obj | ||
# }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
import shop | ||
import account_invoice | ||
import account | ||
import dgii_purchase | ||
import dgii_sale | ||
import res_partner | ||
import account_invoice_state | ||
import dgii_cancel | ||
import dgii_exterior |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
from openerp import models, fields | ||
|
||
|
||
class AccountJournal(models.Model): | ||
_inherit = "account.journal" | ||
|
||
purchase_type = fields.Selection([("normal","Proveedor normal"), | ||
("minor", "Gasto menor"), | ||
("informal", "Proveedor informal"), | ||
("exterior", "Pagos al exterior") | ||
], | ||
string="Tipo de compra", default="normal") | ||
|
||
|
||
class AccountFiscalPosition(models.Model): | ||
_inherit = 'account.fiscal.position' | ||
|
||
supplier = fields.Boolean("Para proveedores") | ||
client_fiscal_type = fields.Selection([ | ||
("final", "Consumidor final"), | ||
("fiscal", "Para credito fiscal"), | ||
("gov", "Gubernamental"), | ||
("special", "Regimenes especiales")], string="Tipo de comprobante") | ||
supplier_fiscal_type = fields.Selection([ | ||
('01', '01 - Gastos de personal'), | ||
('02', '02 - Gastos por trabajo, suministros y servicios'), | ||
('03', '03 - Arrendamientos'), | ||
('04', '04 - Gastos de Activos Fijos'), | ||
('05', u'05 - Gastos de Representación'), | ||
('06', '06 - Otras Deducciones Admitidas'), | ||
('07', '07 - Gastos Financieros'), | ||
('08', '08 - Gastos Extraordinarios'), | ||
('09', '09 - Compras y Gastos que forman parte del Costo de Venta'), | ||
('10', '10 - Adquisiciones de Activos'), | ||
('11', '11 - Gastos de Seguro') | ||
], string="Tipo de gasto") | ||
journal_id = fields.Many2one("account.journal", string="Diario de compra", domain="[('type','=','purchase')]") | ||
|
||
|
||
class AccountTax(models.Model): | ||
_inherit = 'account.tax' | ||
|
||
purchase_tax_type = fields.Selection([('itbis','ITBIS Pagado'),('ritbis','ITBIS Retenido'),('isr','ISR Retenido')], | ||
default="itbis", string="Tipo de impuesto de compra") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from openerp import models, fields, api, exceptions | ||
import requests | ||
from tools import is_ncf, _internet_on | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = "account.invoice" | ||
|
||
|
||
anulation_type = fields.Selection([ | ||
("01", "DETERIORO DE FACTURA PRE-IMPRESA"), | ||
("02", "ERRORES DE IMPRESIÓN (FACTURA PRE-IMPRESA)"), | ||
("03", u"IMPRESIÓN DEFECTUOSA"), | ||
("04", "DUPLICIDAD DE FACTURA"), | ||
("05", "CORRECCIÓN DE LA INFORMACIÓN"), | ||
("06", "CAMBIO DE PRODUCTOS"), | ||
("07", "DEVOLUCIÓN DE PRODUCTOS"), | ||
("08", "OMISIÓN DE PRODUCTOS"), | ||
("09", "ERRORES EN SECUENCIA DE NCF") | ||
], string=u"Tipo de anulación", copy=False) | ||
shop_id = fields.Many2one("shop.ncf.config", string="Sucursal", required=False, | ||
domain=lambda s: s.env["shop.ncf.config"].get_user_shop_domain(), | ||
# default=lambda s: s.env["shop.ncf.config"].get_default_shop() | ||
) | ||
ncf = fields.Char("NCF", size=19, copy=False) | ||
ncf_required = fields.Boolean() | ||
|
||
|
||
_sql_constraints = [ | ||
('number_uniq', 'unique(number, company_id, journal_id, type, partner_id)', 'Invoice Number must be unique per Company!'), | ||
] | ||
|
||
|
||
@api.onchange('journal_id') | ||
def _onchange_journal_id(self): | ||
if self.type in ('in_invoice', 'in_refund'): | ||
self.ncf = False | ||
if self.journal_id.purchase_type == "normal": | ||
self.ncf_required = True | ||
else: | ||
self.ncf_required = False | ||
|
||
return super(AccountInvoice, self)._onchange_journal_id() | ||
|
||
@api.onchange("fiscal_position_id") | ||
def onchange_fiscal_position_id(self): | ||
|
||
if self.type in ('out_invoice', 'out_refund'): | ||
if self.fiscal_position_id.client_fiscal_type == "final": | ||
self.journal_id = self.shop_id.final.id | ||
elif self.fiscal_position_id.client_fiscal_type == "fiscal": | ||
self.journal_id = self.shop_id.fiscal.id | ||
elif self.fiscal_position_id.client_fiscal_type == "gov": | ||
self.journal_id = self.shop_id.gov.id | ||
elif self.fiscal_position_id.client_fiscal_type == "special": | ||
self.journal_id = self.shop_id.special.id | ||
else: | ||
self.journal_id = self.shop_id.final.id | ||
|
||
self.shop_id = self.env["shop.ncf.config"].get_default_shop() | ||
|
||
elif self.type in ('in_invoice', 'in_refund'): | ||
if self.partner_id.journal_id: | ||
self.journal_id = self.partner_id.journal_id.id | ||
else: | ||
self.journal_id = self.fiscal_position_id.journal_id.id | ||
|
||
if self.fiscal_position_id.supplier_fiscal_type in ("01","02","03","04","05","06","07","08","09","10","11"): | ||
self.ncf_required = True | ||
else: | ||
self.ncf_required = False | ||
|
||
def _check_ncf(self, rnc, ncf): | ||
if ncf and rnc: | ||
res = requests.get('http://api.marcos.do/ncf/{}/{}'.format(rnc, ncf)) | ||
if res.status_code == 200: | ||
return res.json() | ||
return {} | ||
|
||
@api.multi | ||
def invoice_ncf_validation(self): | ||
for invoice in self: | ||
if not invoice.journal_id.purchase_type in ['minor', 'informal', 'exterior'] and invoice.ncf_required == True: | ||
|
||
inv_exist = self.search([('partner_id','=',invoice.partner_id.id),('number','=',invoice.ncf),('state','in',('open','paid'))]) | ||
if inv_exist: | ||
raise exceptions.Warning(u"Este número de comprobante ya fue registrado para este proveedor!") | ||
|
||
if not is_ncf(invoice.ncf, invoice.type): | ||
raise exceptions.UserError("El numero de comprobante fiscal no es valido" | ||
"verifique de que no esta digitando un comprobante" | ||
"de consumidor final codigo 02 o revise si lo ha " | ||
"digitado incorrectamente") | ||
|
||
elif _internet_on(): | ||
result = self._check_ncf(invoice.partner_id.vat, invoice.ncf) | ||
if not result.get("valid", False): | ||
raise exceptions.UserError("El numero de comprobante fiscal no es valido! " | ||
"no paso la validacion en DGII, Verifique que el NCF y el RNC del " | ||
"proveedor esten correctamente digitados.") | ||
|
||
self.signal_workflow("invoice_open") | ||
|
||
@api.model | ||
def create(self, vals): | ||
if self._context.get("type", False) in ('in_invoice', 'in_refund') and vals.get("ncf", False): | ||
vals.update({"move_name": vals["ncf"]}) | ||
return super(AccountInvoice, self).create(vals) | ||
|
||
|
||
@api.multi | ||
def write(self, vals): | ||
if vals.get("ncf", False) and self._context.get("type", False) in ('in_invoice', 'in_refund'): | ||
vals.update({"move_name": vals["ncf"]}) | ||
return super(AccountInvoice, self).write(vals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from openerp import models, api, _, fields | ||
from openerp.exceptions import UserError | ||
|
||
|
||
class AccountInvoiceCancel(models.TransientModel): | ||
""" | ||
This wizard will cancel the all the selected invoices. | ||
If in the journal, the option allow cancelling entry is not selected then it will give warning message. | ||
""" | ||
|
||
_inherit = "account.invoice.cancel" | ||
_description = "Cancel the Selected Invoices" | ||
|
||
anulation_type = fields.Selection([ | ||
("01", u"01 - DETERIORO DE FACTURA PRE-IMPRESA"), | ||
("02", u"02 - ERRORES DE IMPRESIÓN (FACTURA PRE-IMPRESA)"), | ||
("03", u"03 - IMPRESIÓN DEFECTUOSA"), | ||
("04", u"04 - DUPLICIDAD DE FACTURA"), | ||
("05", u"05 - CORRECCIÓN DE LA INFORMACIÓN"), | ||
("06", u"06 - CAMBIO DE PRODUCTOS"), | ||
("07", u"07 - DEVOLUCIÓN DE PRODUCTOS"), | ||
("08", u"08 - OMISIÓN DE PRODUCTOS"), | ||
("09", u"09 - ERRORES EN SECUENCIA DE NCF") | ||
], string=u"Tipo de anulación", required=True) | ||
|
||
@api.multi | ||
def invoice_cancel(self): | ||
context = dict(self._context or {}) | ||
active_ids = context.get('active_ids', []) or [] | ||
|
||
for record in self.env['account.invoice'].browse(active_ids): | ||
if record.state in ('cancel', 'paid'): | ||
raise UserError(_("Selected invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state.")) | ||
record.write({"anulation_type": self.anulation_type}) | ||
record.signal_workflow('invoice_cancel') | ||
return {'type': 'ir.actions.act_window_close'} |
Oops, something went wrong.