Parcourir la source

[ADD] print qweb invoice

Gogs il y a 7 ans
Parent
commit
57e87df2dc

+ 7 - 1
models/account_voucher.py

@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+
 from openerp import api, fields, models
 from openerp.exceptions import except_orm
 
@@ -171,4 +172,9 @@ class AccountVoucher(models.Model):
             }] for l in account_move.line_id]
         })
 
-        return account_voucher.action_move_line_create()
+        account_voucher.action_move_line_create()
+
+        return {
+            'action_id': self.env['ir.actions.report.xml'].search([('report_name', '=', 'account.report_invoice')]).id,
+            'invoice_id': invoice.id
+        }

+ 8 - 7
src/components/payment/credit/PaymentCreditAmount.vue

@@ -12,13 +12,13 @@
         .payment-credit-form-table
             table
                 thead
-                    td
-                        th Fecha de Pago
+                    tr
                         th Monto a pagar
+                        th Fecha de Pago
                 tbody
                     tr(v-for="line in totalLines")
+                        td {{ formatAmount(line.total) }}
                         td {{ line.date }}
-                        td {{ line.total }}
 </template>
 
 <script>
@@ -47,8 +47,8 @@
             ])
         },
         methods: {
-            formatTotal() {
-                return accounting.formatMoney(this.total, this.currencySymbol, 0, '.', ',')
+            formatAmount(amount) {
+                return accounting.formatMoney(amount, this.currencySymbol, 0, '.', ',')
             },
             computeAmounts(value) {
                 this.totalLines = []
@@ -105,6 +105,7 @@
         },
         mounted() {
             this.changeAmountPaid(0)
+            this.computeAmounts(this.total)
         }
     }
 </script>
@@ -156,7 +157,7 @@
                             line-height: 35px
                             padding-left: 10px
                         th:nth-child(1)
-                            width: 250px
+                            width: 200px
                         th:nth-child(2)
                             width: 200px
                     tbody
@@ -165,7 +166,7 @@
                             padding-left: 10px
 
                         td:nth-child(1)
-                            width: 250px
+                            width: 200px
                         td:nth-child(2)
                             width: 200px
 </style>

+ 26 - 2
src/store/actions.js

@@ -54,14 +54,38 @@ const actions = {
                 context: new openerp.web.CompoundContext()
             }).then(response => {
                 window.location.reload()
+
+                dispatch('printInvoice', response)
+
                 resolve(response)
             }).fail(error => {
                 reject(error)
             })
         })
     },
-    reset({ state }) {
-        console.log(state)
+    printInvoice({ getters }, payload) {
+        let self = getters.posInstance
+
+        let active_ids = {
+            active_id: payload.invoice_id,
+            active_ids: [payload.invoice_id],
+            active_model: 'account.invoice'
+        }
+
+        self.rpc('/web/action/load', {
+            action_id: payload.action_id,
+            context: new openerp.web.CompoundContext(active_ids).eval()
+        }).then(result => {
+            result.context = new openerp.web.CompoundContext(active_ids).eval();
+            result.flags = result.flags || {};
+            result.flags.new_window = true;
+
+            self.do_action(result, {
+                on_close: function () {
+                    self.getParent().reload();
+                }
+            }) 
+        })
     }
 }
 

+ 1 - 1
src/store/getters.js

@@ -2,7 +2,7 @@ const getters = {
     isLoading(state) {
         return state.loading
     },
-    getPosInstance(state) {
+    posInstance(state) {
         return state.pos_instance
     }
 }