Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
svazquezco committed Mar 6, 2019
1 parent 4653afe commit 4a3a85a
Show file tree
Hide file tree
Showing 21 changed files with 3,758 additions and 9 deletions.
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: python

python:
- 3.5

cache: pip

addons:
apt:
packages:
- expect-dev
- python-lxml

env:
- VERSION="11.0" LINT_CHECK="1"
- VERSION="11.0" ODOO_REPO="odoo/odoo" LINT_CHECK="0"

install:
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
- pip install -r requirements.txt
- travis_install_nightly

script:
- travis_run_tests

after_success:
- travis_after_tests_success
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
.. image:: https://travis-ci.org/svazquezco/l10n_co_electronic_invoice.svg?branch=11.0
:target: https://travis-ci.org/svazquezco/l10n_co_electronic_invoice
:alt: Build Status

.. image:: https://coveralls.io/repos/github/svazquezco/l10n_co_electronic_invoice/badge.svg
:target: https://coveralls.io/github/svazquezco/l10n_co_electronic_invoice
:alt: Coverage Status

.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3


==========================
l10n_co_electronic_invoice
==========================
Expand Down
3 changes: 2 additions & 1 deletion __manifest__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright <2018> <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
Expand All @@ -18,6 +17,8 @@

],
'data': [
'security/ir.model.access.csv',
'data/account_tax_group_data.xml',
'views/account_invoice.xml',
'views/account_journal.xml',
'views/l10n_co_dian_resolution.xml',
Expand Down
61 changes: 61 additions & 0 deletions data/account_tax_group_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">

<record id="tax_group_iva" model="account.tax.group">
<field name="name">IVA</field>
<field name="l10n_co_dian_code">01</field>
</record>

<record id="tax_group_ic" model="account.tax.group">
<field name="name">IC</field>
<field name="l10n_co_dian_code">02</field>
</record>

<record id="tax_group_ica" model="account.tax.group">
<field name="name">ICA</field>
<field name="l10n_co_dian_code">03</field>
</record>

<record id="tax_group_inc" model="account.tax.group">
<field name="name">INC</field>
<field name="l10n_co_dian_code">04</field>
</record>

<record id="tax_group_iva_ret" model="account.tax.group">
<field name="name">ReteIva</field>
<field name="l10n_co_dian_code">05</field>
</record>

<record id="tax_group_rf_ret" model="account.tax.group">
<field name="name">ReteFuente</field>
<field name="l10n_co_dian_code">06</field>
</record>

<record id="tax_group_ica_ret" model="account.tax.group">
<field name="name">ReteICA</field>
<field name="l10n_co_dian_code">06</field>
</record>

<record id="tax_group_cree_ret" model="account.tax.group">
<field name="name">ReteCREE</field>
<field name="l10n_co_dian_code">07</field>
</record>

<record id="tax_group_fto_horti_cult" model="account.tax.group">
<field name="name">FtoHorticultura</field>
<field name="l10n_co_dian_code">08</field>
</record>

<record id="tax_group_timbre" model="account.tax.group">
<field name="name">Timbre</field>
<field name="l10n_co_dian_code">20</field>
</record>

<record id="tax_group_bolsas" model="account.tax.group">
<field name="name">Bolsas</field>
<field name="l10n_co_dian_cod">22</field>
</record>

</data>
</odoo>
1 change: 1 addition & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from . import account_invoice
from . import account_journal
from . import account_tax_group
from . import l10n_co_dian_resolution
from . import l10n_co_electronic_invoice
from . import res_company
Expand Down
35 changes: 35 additions & 0 deletions models/account_invoice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# © 2018 Susana Vázquez <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models
from odoo.exceptions import UserError


class AccountInvoice(models.Model):
Expand All @@ -9,3 +13,34 @@ class AccountInvoice(models.Model):
'invoice_id',
'Electronic invoice'
)

def _prepare_einvoice_vals(self):
return {
'invoice_id': self.id,
'company_id': self.company_id.id,
}

@api.multi
def invoice_validate(self):
res = super(AccountInvoice, self).invoice_validate()
for inv in self.filtered(lambda x: x.company_id.l10n_co_dian_enabled):
einv_vals = self._prepare_einvoice_vals()
einv = self.env['l10n.co.electronic.invoice'].create(einv_vals)
einv.validate_invoice()
einv.action_post_validate()

return res

@api.multi
def action_cancel(self):
res = super(AccountInvoice, self).action_cancel()
for inv in self.filtered(lambda x: x.l10n_co_dian_enabled):
invoice_sent_dian = inv.filtered(
lambda x: x.l10n_co_invoice_electronic_ids.state == 'done')

if invoice_sent_dian:
raise UserError('Can\'t cancel invoice sent to DIAN')

return res


9 changes: 9 additions & 0 deletions models/account_tax_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import api, fields, models


class AccountTaxGroup(models.Model):
_inherit = 'account.tax.group'

l10n_co_dian_code = fields.Integer(
'Dian Code'
)
Loading

0 comments on commit 4a3a85a

Please sign in to comment.