浏览代码

[FIX] config and date

robert 5 年之前
父节点
当前提交
3807e85ed2
共有 4 个文件被更改,包括 31 次插入12 次删除
  1. 8 7
      controllers/res_config.py
  2. 5 1
      src/components/steps/Payment.vue
  3. 3 1
      src/store/modules/date.js
  4. 15 3
      src/store/modules/payment.js

+ 8 - 7
controllers/res_config.py

@@ -6,14 +6,15 @@ _MODEL = 'res.config.settings'
 
 def get_pos_config():
     config = request.env[_MODEL].search([], limit=1, order='id desc')
+    config = config.get_default_settings([])
 
     return {
-        'imageType': config.image_type,
-        'allowCurrencyExchange': config.allow_currency_exchange,
-        'viewCurrencyExchanges': config.view_currency_exchanges,
-        'allowChangeUser': config.allow_change_user,
-        'allowChangeDate': config.allow_change_date,
-        'allowPricelist': config.allow_pricelist,
+        'imageType': config.get('image_type'),
+        'allowCurrencyExchange': config.get('allow_currency_exchange'),
+        'viewCurrencyExchanges': config.get('view_currency_exchanges'),
+        'allowChangeUser': config.get('allow_change_user'),
+        'allowChangeDate': config.get('allow_change_date'),
+        'allowPricelist': config.get('allow_pricelist'),
         'currencies': [
             {
                 'id': currency.id,
@@ -24,7 +25,7 @@ def get_pos_config():
                 'decimalSeparator': currency.decimal_separator,
                 'decimalPlaces': currency.decimal_places,
                 'thousandsSeparator': currency.thousands_separator
-            } for currency in config.currency_ids
+            } for currency in request.env['res.currency'].browse(config.get('currency_ids'))
         ]
     }
 

+ 5 - 1
src/components/steps/Payment.vue

@@ -64,7 +64,7 @@
                     @onClickOption='changePaymentMethod'
                     @onChangeValue='changeAmountReceived($event)'
                 )
-            .form-item(v-show="paymentType === 'credit' && settings.changeDate && (paymentLines && paymentLines.length > 1)")
+            .form-item(v-show='canChangeFirstPaymentDate')
                 label.form-label Primer pago
                 date-picker.form-input(
                     v-model='firstPayment'
@@ -73,6 +73,7 @@
                     format='DD/MM/YYYY'
                     :clearable='false'
                     :editable='false'
+                    append-to-body='true'
                     :not-before='firstPaymentAfterDate'
                 )
             //- input para el vuelto del pago en caso de pago en efectivo
@@ -161,6 +162,7 @@
                 'amountResidual',
                 'paymentLines',
                 'firstPaymentDate',
+                'canChangeFirstPaymentDate',
                 'firstPaymentAfterDate',
                 'cartItems',
                 'paymentType',
@@ -283,6 +285,8 @@
                     label
                         font-size: 12pt
                         margin: 0 35px 15px 5px
+                .mx-datepicker-popup
+                    bottom: unset !important
                 .other_exchanges
                     width: 145px
                     height: 150px

+ 3 - 1
src/store/modules/date.js

@@ -27,9 +27,11 @@ const mutations = {
 }
 
 const actions = {
-    initDate({ commit }, payload) {
+    initDate({ commit, dispatch }, payload) {
         commit('setDate', payload)
         commit('setLoadingDate')
+
+        dispatch('changeFirstPaymentDate', payload)
     },
     resetDate({ getters, commit }) {
         if (!getters.isWired) {

+ 15 - 3
src/store/modules/payment.js

@@ -80,6 +80,13 @@ const getters = {
 
         return state.firstPaymentDate
     },
+    canChangeFirstPaymentDate(state, getters) {
+        const changeDate = getters.settings.changeDate
+        const paymentType = state.paymentType
+        const paymentLines = state.paymentLines
+
+        return changeDate && paymentType === 'credit' && paymentLines.length > 1
+    },
     firstPaymentAfterDate(state) {
         return state.firstPaymentAfterDate
     },
@@ -256,8 +263,14 @@ const actions = {
             dispatch('computePaymentLines')
         }
     },
-    changeFirstPaymentDate({ commit }, paymentDate) {
+    changeFirstPaymentDate({ commit, dispatch, getters }, paymentDate) {
         commit('setFirstPaymentDate', paymentDate)
+
+        if (!getters.paymentTerm) {
+            return
+        }
+        
+        dispatch('computePaymentLines')
     },
     changeBankPaymentData({ commit, dispatch }, bankPaymentData) {
         commit('setBankPaymentData', bankPaymentData)
@@ -268,7 +281,7 @@ const actions = {
     },
     computePaymentLines({ commit, getters }) {
         commit('setPaymentLines', {
-            date: getters.date,
+            date: getters.firstPaymentDate,
             total: getters.amountToPay
         })
     },
@@ -276,7 +289,6 @@ const actions = {
         if (getters.isWired) {
             commit('setLoadingPaymentTerms', true)
             commit('setPaymentTerms', [])
-
         }
         
         commit('setPaymentTerm', null)