Merge branch '5.4' into 044709

This commit is contained in:
Raimon Esteve 2021-10-14 09:55:53 +02:00 committed by GitHub
commit 13186ec8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 431 additions and 14 deletions

View File

@ -1,13 +1,58 @@
diff --git a/trytond/trytond/modules/account_asset/asset.py b/trytond/trytond/modules/account_asset/asset.py
index cf5191f..385cbf1 100644
--- a/trytond/trytond/modules/account_asset/asset.py
+++ b/trytond/trytond/modules/account_asset/asset.py
@@ -823,7 +823,7 @@ class UpdateAsset(Wizard):
Asset = Pool().get('account.asset')
asset = Asset(Transaction().context['active_id'])
return {
- 'amount': self.start.value - asset.value,
+ 'amount': Decimal(self.start.value) - asset.value,
'date': datetime.date.today(),
'depreciation_account': asset.product.account_depreciation_used.id,
'counterpart_account': asset.product.account_expense_used.id,
diff --git a//trytond/trytond/modules/account_asset/asset.py b//trytond/trytond/modules/account_asset/asset.py
index cf5191f..661982a 100644
--- a//trytond/trytond/modules/account_asset/asset.py
+++ b//trytond/trytond/modules/account_asset/asset.py
@@ -745,15 +745,32 @@ class CreateMoves(Wizard):
class UpdateAssetStart(ModelView):
'Update Asset Start'
__name__ = 'account.asset.update.start'
- value = fields.Numeric('Asset Value', required=True)
- residual_value = fields.Numeric('Residual Value', required=True)
+ value = fields.Numeric('Asset Value',
+ digits=(16, Eval('currency_digits', 2)),
+ depends=['currency_digits'], required=True)
+ residual_value = fields.Numeric('Residual Value',
+ digits=(16, Eval('currency_digits', 2)),
+ depends=['currency_digits'], required=True)
end_date = fields.Date('End Date', required=True)
+ currency_digits = fields.Integer('Currency Digits', required=True)
+
+ @staticmethod
+ def default_currency_digits():
+ Asset = Pool().get('account.asset')
+
+ context = Transaction().context
+ active_id = context.get('active_id')
+ if active_id:
+ return Asset(active_id).currency_digits
+ return 2
class UpdateAssetShowDepreciation(ModelView):
'Update Asset Show Depreciation'
__name__ = 'account.asset.update.show_depreciation'
- amount = fields.Numeric('Amount', readonly=True)
+ amount = fields.Numeric('Amount',
+ digits=(16, Eval('currency_digits', 2)),
+ depends=['currency_digits'], readonly=True)
date = fields.Date('Date', required=True,
domain=[
('date', '>', Eval('latest_move_date')),
@@ -769,6 +786,17 @@ class UpdateAssetShowDepreciation(ModelView):
'Depreciation Account', readonly=True)
counterpart_account = fields.Many2One('account.account',
'Counterpart Account')
+ currency_digits = fields.Integer('Currency Digits', required=True)
+
+ @staticmethod
+ def default_currency_digits():
+ Asset = Pool().get('account.asset')
+
+ context = Transaction().context
+ active_id = context.get('active_id')
+ if active_id:
+ return Asset(active_id).currency_digits
+ return 2
class UpdateAsset(Wizard):

22
issue10500.diff Normal file
View File

@ -0,0 +1,22 @@
diff --git a/invoice.py b/invoice.py
index 582265d..1093bb3 100644
--- a/trytond/trytond/modules/account_invoice/invoice.py
+++ b/trytond/trytond/modules/account_invoice/invoice.py
@@ -1202,7 +1202,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
gettext('account_invoice.msg_invoice_same_account_line',
account=self.account.rec_name,
invoice=self.rec_name,
- line=line.rec_name))
+ lines=line.rec_name))
def check_payment_lines(self):
amount = sum(l.debit - l.credit for l in self.lines_to_pay)
@@ -2121,7 +2121,7 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
gettext('account_invoice.msg_invoice_same_account_line',
account=self.account.rec_name,
invoice=self.invoice.rec_name,
- line=self.rec_name))
+ lines=self.rec_name))
def _compute_taxes(self):
pool = Pool()

14
issue10680.diff Normal file
View File

@ -0,0 +1,14 @@
diff --git a/product.py b/product.py
--- a/trytond/trytond/modules/product/product.py
+++ b/trytond/trytond/modules/product/product.py
@@ -282,6 +282,10 @@ class Product(
def get_template(self, name):
value = getattr(self.template, name)
+ if getattr(self.__class__, name)._type == 'reference':
+ if value:
+ return str(value)
+ return value
if isinstance(value, Model):
return value.id
elif (isinstance(value, (list, tuple))

29
issue8776.diff Normal file
View File

@ -0,0 +1,29 @@
diff --git a/trytond/trytond/tools/misc.py b/trytond/trytond/tools/misc.py
index ee2763c9..300b5a72 100644
--- a/trytond/trytond/tools/misc.py
+++ b/trytond/trytond/tools/misc.py
@@ -12,6 +12,8 @@ import types
import io
import warnings
import importlib
+import re
+import unicodedata
from sql import Literal
from sql.operators import Or
@@ -272,3 +274,15 @@ def rstrip_wildcard(string, wildcard='%', escape='\\'):
if new_string[-1] == escape:
return string
return new_string
+
+
+_slugify_strip_re = re.compile(r'[^\w\s-]')
+_slugify_hyphenate_re = re.compile(r'[-\s]+')
+
+
+def slugify(value, hyphenate='-'):
+ if not isinstance(value, str):
+ value = str(value)
+ value = unicodedata.normalize('NFKD', value)
+ value = str(_slugify_strip_re.sub('', value).strip())
+ return _slugify_hyphenate_re.sub(hyphenate, value)

197
issue9049-issue4050.diff Normal file
View File

@ -0,0 +1,197 @@
diff --git a/trytond/trytond/modules/purchase/__init__.py b/trytond/trytond/modules/purchase/__init__.py
index 5f548ca..db72ac1 100644
--- a/trytond/trytond/modules/purchase/__init__.py
+++ b/trytond/trytond/modules/purchase/__init__.py
@@ -36,6 +36,7 @@ def register():
Location,
party.Party,
party.CustomerCode,
+ purchase.ReturnPurchaseStart,
module='purchase', type_='model')
Pool.register(
PurchaseReport,
@@ -47,4 +48,5 @@ def register():
party.PartyReplace,
party.PartyErase,
ModifyHeader,
+ purchase.ReturnPurchase,
module='purchase', type_='wizard')
diff --git a/trytond/trytond/modules/purchase/locale/ca.po b/trytond/trytond/modules/purchase/locale/ca.po
index b184206..e4e01be 100644
--- a/trytond/trytond/modules/purchase/locale/ca.po
+++ b/trytond/trytond/modules/purchase/locale/ca.po
@@ -526,6 +526,10 @@ msgctxt "model:ir.action,name:wizard_modify_header"
msgid "Modify Header"
msgstr "Modificar capçalera"
+msgctxt "model:ir.action,name:wizard_return_purchase"
+msgid "Return Purchase"
+msgstr "Retorna la compra"
+
msgctxt "model:ir.action,name:wizard_shipment_handle_exception"
msgid "Handle Shipment Exception"
msgstr "Gestiona l'excepció d'enviament"
@@ -1015,6 +1019,10 @@ msgctxt "view:purchase.purchase:"
msgid "Purchase"
msgstr "Compra"
+msgctxt "view:purchase.return_purchase.start:"
+msgid "Are you sure to return these/this purchase(s)?"
+msgstr "Esteu segurs que voleu retornar aquesta/es compra/es?"
+
msgctxt "wizard_button:purchase.handle.invoice.exception,ask,end:"
msgid "Cancel"
msgstr "Cancel·la"
diff --git a/trytond/trytond/modules/purchase/locale/es.po b/trytond/trytond/modules/purchase/locale/es.po
index c48d0c8..497e5a3 100644
--- a/trytond/trytond/modules/purchase/locale/es.po
+++ b/trytond/trytond/modules/purchase/locale/es.po
@@ -529,6 +529,10 @@ msgctxt "model:ir.action,name:wizard_modify_header"
msgid "Modify Header"
msgstr "Modificar cabecera"
+msgctxt "model:ir.action,name:wizard_return_purchase"
+msgid "Return Purchase"
+msgstr "Devolver la compra"
+
msgctxt "model:ir.action,name:wizard_shipment_handle_exception"
msgid "Handle Shipment Exception"
msgstr "Gestionar excepción de envío"
@@ -1018,6 +1022,10 @@ msgctxt "view:purchase.purchase:"
msgid "Purchase"
msgstr "Compra"
+msgctxt "view:purchase.return_purchase.start:"
+msgid "Are you sure to return these/this purchase(s)?"
+msgstr "¿Estás seguro de querer devolver este/os pedido/s de compra?"
+
msgctxt "wizard_button:purchase.handle.invoice.exception,ask,end:"
msgid "Cancel"
msgstr "Cancelar"
diff --git a/trytond/trytond/modules/purchase/purchase.py b/trytond/trytond/modules/purchase/purchase.py
index a0459a5..4e35105 100644
--- a/trytond/trytond/modules/purchase/purchase.py
+++ b/trytond/trytond/modules/purchase/purchase.py
@@ -175,6 +175,11 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
invoices_recreated = fields.Many2Many(
'purchase.purchase-recreated-account.invoice',
'purchase', 'invoice', 'Recreated Invoices', readonly=True)
+ origin = fields.Reference('Origin', selection='get_origin', select=True,
+ states={
+ 'readonly': Eval('state') != 'draft',
+ },
+ depends=['state'])
delivery_date = fields.Date(
"Delivery Date",
states={
@@ -575,6 +580,17 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin):
self.write([self], {
'shipment_state': state,
})
+ @classmethod
+ def _get_origin(cls):
+ "Return list of Model names for origin Reference"
+ return ['purchase.purchase']
+
+ @classmethod
+ def get_origin(cls):
+ Model = Pool().get('ir.model')
+ get_name = Model.get_name
+ models = cls._get_origin()
+ return [(None, '')] + [(m, get_name(m)) for m in models]
@property
def report_address(self):
@@ -1864,3 +1880,37 @@ class ModifyHeader(Wizard):
Line.save(purchase.lines)
return 'end'
+
+
+class ReturnPurchaseStart(ModelView):
+ "Return Purchase"
+ __name__ = 'purchase.return_purchase.start'
+
+
+class ReturnPurchase(Wizard):
+ "Return Purchase"
+ __name__ = 'purchase.return_purchase'
+ start = StateView('purchase.return_purchase.start',
+ 'purchase.return_purchase_start_view_form', [
+ Button("Cancel", 'end', 'tryton-cancel'),
+ Button("Return", 'return_', 'tryton-ok', default=True),
+ ])
+ return_ = StateAction('purchase.act_purchase_form')
+
+ def do_return_(self, action):
+ Purchase = Pool().get('purchase.purchase')
+
+ purchases = Purchase.browse(Transaction().context['active_ids'])
+ return_purchases = Purchase.copy(purchases)
+ for return_purchase, purchase in zip(return_purchases, purchases):
+ return_purchase.origin = purchase
+ for line in return_purchase.lines:
+ if line.type == 'line':
+ line.quantity *= -1
+ return_purchase.lines = return_purchase.lines # Force saving
+ Purchase.save(return_purchases)
+
+ data = {'res_id': [s.id for s in return_purchases]}
+ if len(return_purchases) == 1:
+ action['views'].reverse()
+ return action, data
diff --git a/trytond/trytond/modules/purchase/purchase.xml b/trytond/trytond/modules/purchase/purchase.xml
index aef771b..97404cb 100644
--- a/trytond/trytond/modules/purchase/purchase.xml
+++ b/trytond/trytond/modules/purchase/purchase.xml
@@ -523,6 +523,22 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">template_tree</field>
</record>
+ <record model="ir.ui.view" id="return_purchase_start_view_form">
+ <field name="model">purchase.return_purchase.start</field>
+ <field name="type">form</field>
+ <field name="name">return_purchase_start_form</field>
+ </record>
+ <record model="ir.action.wizard" id="wizard_return_purchase">
+ <field name="name">Return Purchase</field>
+ <field name="wiz_name">purchase.return_purchase</field>
+ <field name="model">purchase.purchase</field>
+ </record>
+ <record model="ir.action.keyword" id="act_wizard_return_purchase_keyword">
+ <field name="keyword">form_action</field>
+ <field name="model">purchase.purchase,-1</field>
+ <field name="action" ref="wizard_return_purchase"/>
+ </record>
+
<record model="ir.action.wizard" id="act_open_supplier">
<field name="name">Parties associated to Purchases</field>
<field name="wiz_name">purchase.open_supplier</field>
diff --git a/trytond/trytond/modules/purchase/view/purchase_form.xml b/trytond/trytond/modules/purchase/view/purchase_form.xml
index d689f5e..5f25f91 100644
--- a/trytond/trytond/modules/purchase/view/purchase_form.xml
+++ b/trytond/trytond/modules/purchase/view/purchase_form.xml
@@ -45,6 +45,8 @@ this repository contains the full copyright notices and license terms. -->
<label name="company"/>
<field name="company"/>
<newline/>
+ <label name="origin"/>
+ <field name="origin"/>
<label name="invoice_method"/>
<field name="invoice_method"/>
<label name="delivery_date"/>
diff --git a/trytond/trytond/modules/purchase/view/return_purchase_start_form.xml b/trytond/trytond/modules/purchase/view/return_purchase_start_form.xml
new file mode 100644
index 0000000..9a87dd8
--- /dev/null
+++ b/trytond/trytond/modules/purchase/view/return_purchase_start_form.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<form col="2">
+ <image name="tryton-warning" xexpand="0" xfill="0"/>
+ <label
+ string="Are you sure to return these/this purchase(s)?"
+ id="return" yalign="0.0" xalign="0.0" xexpand="1"/>
+</form>

87
issue9122.diff Normal file
View File

@ -0,0 +1,87 @@
diff --git a/trytond/trytond/modules/stock_supply/__init__.py b/trytond/trytond/modules/stock_supply/__init__.py
index 48ced90..0d646e9 100644
--- a/trytond/trytond/modules/stock_supply/__init__.py
+++ b/trytond/trytond/modules/stock_supply/__init__.py
@@ -8,6 +8,7 @@ from .purchase_request import *
from .shipment import *
from .location import *
from . import stock
+from . import ir
def register():
@@ -22,6 +23,7 @@ def register():
Location,
LocationLeadTime,
stock.StockSupplyStart,
+ ir.Cron,
module='stock_supply', type_='model')
Pool.register(
stock.StockSupply,
diff --git a/trytond/trytond/modules/stock_supply/ir.py b/trytond/trytond/modules/stock_supply/ir.py
new file mode 100644
index 0000000..27960e0
--- /dev/null
+++ b/trytond/trytond/modules/stock_supply/ir.py
@@ -0,0 +1,14 @@
+# The COPYRIGHT file at the top level of this repository contains the full
+# copyright notices and license terms.
+from trytond.pool import PoolMeta
+
+
+class Cron(metaclass=PoolMeta):
+ __name__ = 'ir.cron'
+
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ cls.method.selection.extend([
+ ('stock.order_point|supply_stock', "Supply Stock"),
+ ])
diff --git a/trytond/trytond/modules/stock_supply/order_point.py b/trytond/trytond/modules/stock_supply/order_point.py
index 78edc42..e310f0a 100644
--- a/trytond/trytond/modules/stock_supply/order_point.py
+++ b/trytond/trytond/modules/stock_supply/order_point.py
@@ -4,6 +4,7 @@ from sql import Null
from trytond.i18n import gettext
from trytond.model import ModelView, ModelSQL, fields
+from trytond.pool import Pool
from trytond.pyson import If, Equal, Eval, Not, In
from trytond.transaction import Transaction
@@ -251,3 +252,11 @@ class OrderPoint(ModelSQL, ModelView):
@staticmethod
def default_company():
return Transaction().context.get('company')
+
+ @classmethod
+ def supply_stock(cls):
+ pool = Pool()
+ StockSupply = pool.get('stock.supply', type='wizard')
+ session_id, _, _ = StockSupply.create()
+ StockSupply.execute(session_id, {}, 'create_')
+ StockSupply.delete(session_id)
diff --git a/trytond/trytond/modules/stock_supply/tests/scenario_stock_internal_supply.rst b/trytond/trytond/modules/stock_supply/tests/scenario_stock_internal_supply.rst
index d1681fd..eed49a5 100644
--- a/trytond/trytond/modules/stock_supply/tests/scenario_stock_internal_supply.rst
+++ b/trytond/trytond/modules/stock_supply/tests/scenario_stock_internal_supply.rst
@@ -178,3 +178,18 @@ Execute internal supply::
'Provisioning Location'
>>> move.to_location.name
'Second Storage'
+
+Create stock_supply cron and execute it::
+
+ >>> Cron = Model.get('ir.cron')
+ >>> admin_user, = User.find([('login', '=', 'admin')])
+ >>> set_user(admin_user)
+ >>> shipment.delete()
+ >>> cron = Cron(method='stock.order_point|supply_stock')
+ >>> cron.interval_number = 1
+ >>> cron.interval_type = 'months'
+ >>> cron.click('run_once')
+ >>> shipment, = ShipmentInternal.find(
+ ... [('to_location', '=', sec_storage_loc.id)])
+ >>> shipment.state
+ 'request'

12
series
View File

@ -1,10 +1,11 @@
babi_multiprocess.diff # [trytond] babi multiprocess
trytond_test_database.diff # [trytond] avoid errors on upgrades from version 3.4
logging_jsonrpc_exeption.diff # [trytond] logging JSONRPC Exception
issue8776.diff # [trytond] Add slugify tool
account_payment_view.diff # [account_payment]
account_payment_sepa_locale.diff # [account_payment_sepa]
issue3932.diff # [account] rule account move and account move line by company
issue6253.diff # [account_invoice] add invoice type criteria
@ -98,3 +99,12 @@ issue10338.diff # [bank] Search on rec_name of other model in search_rec_name
issue9146.diff # [account_stock_landed_cost] Use field digits on secondary unit
issue4440.diff # [party_relationship] add start/end dates
stock_lot_sled_ca_locale.diff # [stock_lot_sled] Fix wrong translation [#044921]
issue9122.diff # [stock_supply] Add cron job to supply stock
issue10500.diff # [account_invoice] Fix msg_invoice_same_account_line variables name
issue9049-issue4050.diff # [purchase] Add origin and set on returned purchase + Add return wizard
issue10680.diff # [product] Fix get_template in reference field case

View File

@ -0,0 +1,13 @@
diff --git a/locale/ca.po b/locale/ca.po
index 3f35fe7..338625c 100644
--- a/trytond/trytond/modules/stock_lot_sled/locale/ca.po
+++ b/trytond/trytond/modules/stock_lot_sled/locale/ca.po
@@ -101,7 +101,7 @@ msgid ""
"You cannot close periods before the expiration of lot \"%(lot)s\" "
"(%(date)s)."
msgstr ""
-"No podeu tancar períodes abans de l'expiració del lot \"%(lots)\" (%date)s)."
+"No podeu tancar períodes abans de l'expiració del lot \"%(lot)s\" (%(date)s)."
msgctxt "model:res.group,name:group_stock_force_expiration"
msgid "Stock Force Expiration"