Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] l10n_br_nfe_med #57

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions l10n_br_nfe_med/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
===============
L10n Br Nfe Med
===============

Informação de Medicamentos na NF-e

Configuration
=============

To configure this module, you need to:

#. Go to ...

Usage
=====

To use this module, you need to:

#. Go to ...


Changelog
=========
1 change: 1 addition & 0 deletions l10n_br_nfe_med/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions l10n_br_nfe_med/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Informação de Medicamentos na NF-e",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "KMEE",
"website": "https://github.com/KMEE/kmee-odoo-addons",
"depends": [
"l10n_br_account_nfe",
],
"data": [
"views/product_template.xml",
"views/document_line.xml",
],
}
3 changes: 3 additions & 0 deletions l10n_br_nfe_med/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import product_template
from . import document_line
from . import nfe_40_med
13 changes: 13 additions & 0 deletions l10n_br_nfe_med/models/document_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class DocumentLine(models.Model):
_inherit = "l10n_br_fiscal.document.line"

nfe40_med = fields.Many2one(
related="product_id.nfe40_med",
store=True,
)
25 changes: 25 additions & 0 deletions l10n_br_nfe_med/models/nfe_40_med.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2024 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class Nfe40Med(models.AbstractModel):
_inherit = "nfe.40.med"

_rec_name = "nfe40_cProdANVISA"

@api.depends("nfe40_cProdANVISA", "nfe40_xMotivoIsencao", "nfe40_vPMC")
def _compute_display_name(self):
super()._compute_display_name()

def name_get(self):
res = []
for record in self:
name = record.nfe40_cProdANVISA
if record.nfe40_xMotivoIsencao:
name += " - " + record.nfe40_xMotivoIsencao
if record.nfe40_vPMC:
name += " - " + record.nfe40_vPMC
res.append((record.id, name))
return res
17 changes: 17 additions & 0 deletions l10n_br_nfe_med/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 KMEE
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductTemplate(models.Model):

_inherit = "product.template"

nfe40_med = fields.Many2one(
comodel_name="nfe.40.med",
# delegate=True,
)

# eu tinha tentado fazer o delegate, mas não ficou bom,
# da pra tentar fazer uma abordagem com Stacked.
52 changes: 52 additions & 0 deletions l10n_br_nfe_med/views/document_line.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 KMEE
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<!-- <record id="view_move_form_inherit" model="ir.ui.view">
<field name="model">account.move</field>
<field name="inherit_id" ref="l10n_br_account.invoice_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/form//page[@name='fiscal_line_extra_info']" position="after">
<page name="med" string="Medicamento">
<group >
<field name="nfe40_med"/>
</group>
</page>
</xpath>
<xpath expr="//field[@name='line_ids']/tree" position="inside">
<field name="nfe40_med" invisible="1" />
</xpath>
</field>
</record> -->


<record model="ir.ui.view" id="document_line_form">
<field name="model">l10n_br_fiscal.document.line</field>
<field name="inherit_id" ref="l10n_br_fiscal.document_line_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='fiscal_line_extra_info']" position="after">
<page name="med" string="Medicamento">
<group>
<field name="nfe40_med" />
</group>
</page>
</xpath>
</field>
</record>

<!-- <record model="ir.ui.view" id="document_fiscal_line_mixin_form">
<field name="model">l10n_br_fiscal.document.line</field>
<field name="inherit_id" ref="l10n_br_fiscal.document_fiscal_line_mixin_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='fiscal_line_extra_info']" position="after">
<page name="med" string="Medicamento">
<group >
<field name="nfe40_med"/>
</group>
</page>
</xpath>
</field>
</record> -->

</odoo>
30 changes: 30 additions & 0 deletions l10n_br_nfe_med/views/product_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 KMEE
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.ui.view" id="product_template_form_view">
<field name="model">product.template</field>
<field name="inherit_id" ref="l10n_br_fiscal.product_template_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='fiscal']/group" position="after">
<group name="med" string="Medicamento">
<field name="nfe40_med" />
<!-- <field name="nfe40_cProdANVISA" string="Código ANVISA"/>
<field name="nfe40_xMotivoIsencao" string="Motivo Isencao"/>
<field name="nfe40_vPMC"/> -->
</group>
</xpath>
</field>
</record>

<!-- <record model="ir.ui.view" id="product_template_search_view">
<field name="model">product.template</field>
<field name="inherit_id" ref="TODO othermodule.search_view"/>
<field name="arch" type="xml">

</field>
</record> -->


</odoo>
1 change: 1 addition & 0 deletions setup/l10n_br_nfe_med/odoo/addons/l10n_br_nfe_med
6 changes: 6 additions & 0 deletions setup/l10n_br_nfe_med/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading