Skip to content
Permalink
Browse files

[ADD] account: add ocr to customer invoices

Task 1942983
Accounting firms need to upload PDF of customer invoices and refunds (not only vendor bills).
  • Loading branch information...
william-andre committed Mar 6, 2019
1 parent 83abca9 commit ca6df557a34198375fb51ff83888a570623e657e
@@ -8,10 +8,11 @@ class ImportInvoiceImportWizard(models.TransientModel):
_description = 'Import Your Vendor Bills from Files.'

def _get_default_journal_id(self):
return self.env['account.journal'].search([('type', '=', 'purchase')], limit=1)
type = self.env.context.get('type') == 'out_invoice' and 'sale' or 'purchase'
return self.env['account.journal'].search([('type', '=', type)], limit=1)

attachment_ids = fields.Many2many('ir.attachment', string='Files')
journal_id = fields.Many2one(string="Journal", comodel_name="account.journal", required=True, domain="[('type', '=', 'purchase')]", default=_get_default_journal_id, help="Journal where to generate the bills")
journal_id = fields.Many2one(string="Journal", comodel_name="account.journal", required=True, domain="[('type', 'in', ('sale', 'purchase'))]", default=_get_default_journal_id, help="Journal where to generate the bills")

@api.multi
def _create_invoice_from_file(self, attachment):
@@ -22,7 +22,6 @@ odoo.define('account.bills.tree', function (require) {
this.$buttons.on('click', '.o_button_upload_bill', function () {
var state = self.model.get(self.handle, {raw: true});
var context = state.getContext()
context['type'] = 'in_invoice'
self.do_action({
type: 'ir.actions.act_window',
res_model: 'account.invoice.import.wizard',
@@ -41,5 +40,5 @@ odoo.define('account.bills.tree', function (require) {
}),
});

viewRegistry.add('account_bills_tree', BillsListView);
viewRegistry.add('account_tree', BillsListView);
});
@@ -153,7 +153,7 @@
<field name="name">account.invoice.tree</field>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" string="Invoice">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" string="Invoice" js_class="account_tree">
<field name="partner_id" groups="base.group_user" string="Customer"/>
<field name="date_invoice"/>
<field name="number"/>
@@ -233,7 +233,7 @@
<field name="name">account.invoice.supplier.tree</field>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" decoration-bf="not partner_id" string="Vendor Bill" js_class="account_bills_tree">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" decoration-bf="not partner_id" string="Vendor Bill" js_class="account_tree">
<field name="partner_id" invisible="1"/>
<field name="source_email" invisible="1"/>
<field name="invoice_icon" string=" "/>
@@ -631,6 +631,7 @@
</page>
</notebook>
</sheet>
<div class="o_attachment_preview" attrs="{'invisible': ['|',('type', '!=', 'out_invoice'),('state', '!=', 'draft')]}" />
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="activity_ids" widget="mail_activity"/>
@@ -276,6 +276,9 @@
<button type="object" name="action_create_new" class="btn btn-primary o_invoice_new">
<span>New Invoice</span>
</button>
<button type="action" name="%(account_invoice_import_wizard_action)d" class="btn btn-primary">
<span>Import Invoices</span>
</button>
</t>
<t t-if="journal_type == 'purchase'">
<button type="object" name="action_create_new" class="btn btn-primary">

0 comments on commit ca6df55

Please sign in to comment.
You can’t perform that action at this time.