Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
sinergia | d76b7ac665 | |
sinergia | 16ba7a72a3 | |
Rodia | 0cc68ace9e | |
sinergia | 34be4741fd | |
Cosmos | 2ac26aeb52 | |
yo | 4dc77893fd | |
raskolnikov1984 | 30289c1667 | |
espurio | fa1b020775 | |
onecluster | c06ba9875e |
14
__init__.py
14
__init__.py
|
@ -2,17 +2,17 @@
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from .purchase import *
|
from . import purchase
|
||||||
__all__ = ['register']
|
__all__ = ['register']
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
Configuration,
|
purchase.Configuration,
|
||||||
Purchase,
|
purchase.Purchase,
|
||||||
module='one_click_for_purchase', type_='model')
|
module='purchase_one_click', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
OneClickForPurchase,
|
purchase.OneClickForPurchase,
|
||||||
module='one_click_for_purchase', type_='wizard')
|
module='purchase_one_click', type_='wizard')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
module='one_click_for_purchase', type_='report')
|
module='purchase_one_click', type_='report')
|
||||||
|
|
109
purchase.py
109
purchase.py
|
@ -1,58 +1,54 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from trytond.wizard import Wizard, StateAction, StateView, StateTransition, \
|
from trytond.wizard import Wizard, StateTransition
|
||||||
Button
|
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
import logging
|
import logging
|
||||||
from trytond.model import (ModelView, ModelSQL, ModelSingleton, ValueMixin,
|
from trytond.model import (
|
||||||
fields)
|
ModelView, fields)
|
||||||
from trytond.modules.company.model import (
|
|
||||||
CompanyMultiValueMixin, CompanyValueMixin)
|
|
||||||
from trytond.model.workflow import Workflow
|
|
||||||
from trytond.modules.account.tax import TaxableMixin
|
|
||||||
from trytond.pyson import Eval
|
from trytond.pyson import Eval
|
||||||
from .exceptions import ErroresGenerales
|
from .exceptions import ErroresGenerales
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['OneClickForPurchase','Configuration','Purchase']
|
__all__ = ['OneClickForPurchase', 'Configuration', 'Purchase']
|
||||||
|
|
||||||
|
|
||||||
class Configuration(metaclass=PoolMeta):
|
class Configuration(metaclass=PoolMeta):
|
||||||
'Purchase Configuration'
|
'Purchase Configuration'
|
||||||
|
|
||||||
__name__ = 'purchase.configuration'
|
__name__ = 'purchase.configuration'
|
||||||
|
|
||||||
one_click_to_location = fields.Many2One('stock.location', 'Destino de Compra',
|
one_click_to_location = fields.Many2One(
|
||||||
domain=[('active','=',True),('type','=','storage')],
|
'stock.location', 'Destino de Compra',
|
||||||
help='Destino de Compra para el modulo one_click_for_purchase'
|
domain=[('active', '=', True), ('type', '=', 'storage')],
|
||||||
)
|
help='Destino de Compra para el modulo purchase_one_click'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Purchase(metaclass=PoolMeta):
|
class Purchase(metaclass=PoolMeta):
|
||||||
'Purchase'
|
'Purchase'
|
||||||
|
|
||||||
__name__ = 'purchase.purchase'
|
__name__ = 'purchase.purchase'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(Purchase, cls).__setup__()
|
super(Purchase, cls).__setup__()
|
||||||
cls._buttons.update({
|
cls._buttons.update({
|
||||||
'draft_to_done': {
|
'draft_to_done': {
|
||||||
'invisible': ~Eval('state').in_(['draft']),
|
'invisible': ~Eval('state').in_(['draft']),
|
||||||
'readonly': ~Eval('lines', []),
|
'readonly': ~Eval('lines', []),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
def draft_to_done(cls,purchases):
|
def draft_to_done(cls, purchases):
|
||||||
'''Lleva las compras (ids) desde el estado borrador hasta finalizados aprobando
|
'''Lleva las compras (ids) desde el estado borrador hasta finalizados
|
||||||
las facturas y movimientos necesarios.'''
|
aprobando las facturas y movimientos necesarios.'''
|
||||||
|
|
||||||
Invoice = Pool().get('account.invoice')
|
Invoice = Pool().get('account.invoice')
|
||||||
Move = Pool().get('stock.move')
|
Move = Pool().get('stock.move')
|
||||||
Configuration = Pool().get('purchase.configuration')
|
Configuration = Pool().get('purchase.configuration')
|
||||||
|
@ -61,25 +57,40 @@ class Purchase(metaclass=PoolMeta):
|
||||||
if purchases:
|
if purchases:
|
||||||
for purchase in purchases:
|
for purchase in purchases:
|
||||||
if purchase.state != 'draft' or len(purchase.lines) < 1:
|
if purchase.state != 'draft' or len(purchase.lines) < 1:
|
||||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_noborrador_sinlineas').format(s=purchase.number))
|
raise ErroresGenerales(
|
||||||
|
gettext(
|
||||||
|
'purchase_one_click.msg_noborrador_sinlineas'
|
||||||
|
).format(
|
||||||
|
s=purchase.number))
|
||||||
return
|
return
|
||||||
if not purchase.invoice_address:
|
if not purchase.invoice_address:
|
||||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_error_direccion').format(p=purchase.id))
|
raise ErroresGenerales(
|
||||||
|
gettext(
|
||||||
|
'purchase_one_click.msg_error_direccion'
|
||||||
|
).format(
|
||||||
|
p=purchase.id))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_error_ventanas'))
|
raise ErroresGenerales(
|
||||||
|
gettext('purchase_one_click.msg_error_ventanas'))
|
||||||
return
|
return
|
||||||
|
|
||||||
cls.set_purchase_date(purchases)#pone fecha de compra a los registros que no lo tienen
|
# pone fecha de compra a los registros que no lo tienen
|
||||||
|
cls.set_purchase_date(purchases)
|
||||||
cls.quote(purchases)
|
cls.quote(purchases)
|
||||||
cls.confirm(purchases)
|
cls.confirm(purchases)
|
||||||
cls.process(purchases)
|
cls.process(purchases)
|
||||||
Transaction().commit()#se graba la informacion para poder acceder a las facturas y los movimientos
|
# se graba la informacion para poder acceder a las facturas y
|
||||||
purchases = cls.browse([x.id for x in purchases])#se vuelve a leer para cargar informacion de la base de datos, verificar si es necesario.
|
# los movimientos
|
||||||
purchases = [x for x in purchases if (x.state == 'processing' and len(x.lines) > 0) ]
|
Transaction().commit()
|
||||||
if len(purchases) <= 0 :
|
# se vuelve a leer para cargar informacion de la base de datos,
|
||||||
raise ErroresGenerales(gettext('one_click_for_purchase.msg_fallo_finalizacion'))
|
# verificar si es necesario.
|
||||||
return
|
purchases = cls.browse([x.id for x in purchases])
|
||||||
|
purchases = [x for x in purchases if (
|
||||||
|
x.state == 'processing' and len(x.lines) > 0)]
|
||||||
|
if len(purchases) <= 0:
|
||||||
|
raise ErroresGenerales(
|
||||||
|
gettext('one_click_for_purchase.msg_fallo_finalizacion'))
|
||||||
for purchase in purchases:
|
for purchase in purchases:
|
||||||
invoices = purchase.invoices
|
invoices = purchase.invoices
|
||||||
if invoices:
|
if invoices:
|
||||||
|
@ -89,24 +100,25 @@ class Purchase(metaclass=PoolMeta):
|
||||||
Invoice.save([invoice])
|
Invoice.save([invoice])
|
||||||
Invoice.validate_invoice(invoices)
|
Invoice.validate_invoice(invoices)
|
||||||
Invoice.post(invoices)
|
Invoice.post(invoices)
|
||||||
|
|
||||||
shipment_returns = purchase.shipment_returns
|
shipment_returns = purchase.shipment_returns
|
||||||
|
|
||||||
if shipment_returns:
|
if shipment_returns:
|
||||||
print("shipment_returns")
|
print("shipment_returns")
|
||||||
for shipment_return in shipment_returns:
|
for shipment_return in shipment_returns:
|
||||||
if shipment_return.from_location != configuration.one_click_to_location:
|
one_click_to_location = configuration.one_click_to_location
|
||||||
shipment_return.from_location = configuration.one_click_to_location
|
if shipment_return.from_location != one_click_to_location:
|
||||||
|
shipment_return.from_location = one_click_to_location
|
||||||
shipment_return.effective_date = purchase.purchase_date
|
shipment_return.effective_date = purchase.purchase_date
|
||||||
shipment_return.assign_force([shipment_return])
|
shipment_return.wait([shipment_return])
|
||||||
|
shipment_return.assign_try([shipment_return])
|
||||||
shipment_return.done([shipment_return])
|
shipment_return.done([shipment_return])
|
||||||
shipment_return.save()
|
shipment_return.save()
|
||||||
#assert not purchase.shipments
|
|
||||||
moves = purchase.moves
|
moves = purchase.moves
|
||||||
if moves:
|
if moves:
|
||||||
for move in moves:
|
for move in moves:
|
||||||
if move.shipment:
|
if move.shipment:
|
||||||
continue
|
continue
|
||||||
if move.to_location != configuration.one_click_to_location:
|
if configuration.one_click_to_location is not None:
|
||||||
move.to_location = configuration.one_click_to_location
|
move.to_location = configuration.one_click_to_location
|
||||||
move.effective_date = purchase.purchase_date
|
move.effective_date = purchase.purchase_date
|
||||||
Move.save([move])
|
Move.save([move])
|
||||||
|
@ -116,16 +128,17 @@ class Purchase(metaclass=PoolMeta):
|
||||||
|
|
||||||
class OneClickForPurchase(Wizard):
|
class OneClickForPurchase(Wizard):
|
||||||
'''Compra en un click.
|
'''Compra en un click.
|
||||||
|
|
||||||
Procesa una compra en estado de borrador llevandola al estado "procesada",
|
Procesa una compra en estado de borrador llevandola al estado "procesada",
|
||||||
creando las Facturas y Movimientos de Stock, además contabiliza la factura
|
creando las Facturas y Movimientos de Stock, además contabiliza la factura
|
||||||
y cambia el movimiento de stock de la entrada al almacenamiento y finaliza los movimientos de stock.
|
y cambia el movimiento de stock de la entrada al almacenamiento y finaliza
|
||||||
|
los movimientos de stock.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
__name__ = 'purchase.one_click_for_purchase'
|
__name__ = 'purchase.one_click_for_purchase'
|
||||||
|
|
||||||
start = StateTransition()
|
start = StateTransition()
|
||||||
|
|
||||||
def transition_start(self):
|
def transition_start(self):
|
||||||
Purchase = Pool().get('purchase.purchase')
|
Purchase = Pool().get('purchase.purchase')
|
||||||
purchases = Purchase.browse(Transaction().context['active_ids'])
|
purchases = Purchase.browse(Transaction().context['active_ids'])
|
||||||
|
|
35
setup.py
35
setup.py
|
@ -24,9 +24,10 @@ def get_require_version(name):
|
||||||
else:
|
else:
|
||||||
require = '%s >= %s.%s, < %s.%s'
|
require = '%s >= %s.%s, < %s.%s'
|
||||||
require %= (name, major_version, minor_version,
|
require %= (name, major_version, minor_version,
|
||||||
major_version, minor_version + 1)
|
major_version, minor_version + 1)
|
||||||
return require
|
return require
|
||||||
|
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.readfp(open('tryton.cfg'))
|
config.readfp(open('tryton.cfg'))
|
||||||
info = dict(config.items('tryton'))
|
info = dict(config.items('tryton'))
|
||||||
|
@ -37,7 +38,7 @@ version = info.get('version', '0.0.1')
|
||||||
major_version, minor_version, _ = version.split('.', 2)
|
major_version, minor_version, _ = version.split('.', 2)
|
||||||
major_version = int(major_version)
|
major_version = int(major_version)
|
||||||
minor_version = int(minor_version)
|
minor_version = int(minor_version)
|
||||||
name = 'trytond_one_click_for_purchase'
|
name = 'trytond_purchase_one_click'
|
||||||
|
|
||||||
download_url = 'http://downloads.tryton.org/%s.%s/' % (
|
download_url = 'http://downloads.tryton.org/%s.%s/' % (
|
||||||
major_version, minor_version)
|
major_version, minor_version)
|
||||||
|
@ -58,33 +59,35 @@ dependency_links = []
|
||||||
if minor_version % 2:
|
if minor_version % 2:
|
||||||
dependency_links.append('https://trydevpi.tryton.org/')
|
dependency_links.append('https://trydevpi.tryton.org/')
|
||||||
|
|
||||||
setup(name=name,
|
setup(
|
||||||
|
name=name,
|
||||||
version=version,
|
version=version,
|
||||||
description='The one_click_for_purchase module for Tryton ERP',
|
description='The purchase_one_click module for Tryton ERP',
|
||||||
long_description=read('README'),
|
long_description=read('README'),
|
||||||
author='Tryton',
|
author='Tryton',
|
||||||
author_email='issue_tracker@tryton.org',
|
author_email='issue_tracker@tryton.org',
|
||||||
url='http://www.tryton.org/',
|
url='http://www.tryton.org/',
|
||||||
download_url=download_url,
|
download_url=download_url,
|
||||||
keywords='purchase, simplify, trytond, trytond_purchase',
|
keywords='purchase, simplify, trytond, trytond_purchase',
|
||||||
package_dir={'trytond.modules.one_click_for_purchase': '.'},
|
package_dir={'trytond.modules.purchase_one_click': '.'},
|
||||||
packages=(
|
packages=(
|
||||||
['trytond.modules.one_click_for_purchase'] +
|
['trytond.modules.purchase_one_click'] +
|
||||||
['trytond.modules.one_click_for_purchase.%s' % p for p in find_packages()]
|
['trytond.modules.purchase_one_click.%s' % p for p in find_packages()]
|
||||||
),
|
),
|
||||||
package_data={
|
package_data={
|
||||||
'trytond.modules.one_click_for_purchase': (info.get('xml', [])
|
'trytond.modules.purchase_one_click': (
|
||||||
|
info.get('xml', [])
|
||||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.fodt',
|
||||||
'icons/*.svg', 'tests/*.rst']),
|
'icons/*.svg', 'tests/*.rst']),
|
||||||
},
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Plugins',
|
'Environment :: Plugins',
|
||||||
'Framework :: Tryton',
|
'Framework :: Tryton',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: Financial and Insurance Industry',
|
'Intended Audience :: Financial and Insurance Industry',
|
||||||
'Intended Audience :: Legal Industry',
|
'Intended Audience :: Legal Industry', 'License:: OSI Approved::\
|
||||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
GNU General Public License v3 or later (GPLv3 +)',
|
||||||
'Natural Language :: Bulgarian',
|
'Natural Language :: Bulgarian',
|
||||||
'Natural Language :: Catalan',
|
'Natural Language :: Catalan',
|
||||||
'Natural Language :: Chinese (Simplified)',
|
'Natural Language :: Chinese (Simplified)',
|
||||||
|
@ -109,17 +112,17 @@ setup(name=name,
|
||||||
'Programming Language :: Python :: Implementation :: CPython',
|
'Programming Language :: Python :: Implementation :: CPython',
|
||||||
'Programming Language :: Python :: Implementation :: PyPy',
|
'Programming Language :: Python :: Implementation :: PyPy',
|
||||||
'Topic :: Office/Business',
|
'Topic :: Office/Business',
|
||||||
],
|
],
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
dependency_links=dependency_links,
|
dependency_links=dependency_links,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
entry_points="""
|
entry_points="""
|
||||||
[trytond.modules]
|
[trytond.modules]
|
||||||
one_click_for_purchase = trytond.modules.one_click_for_purchase
|
purchase_one_click = trytond.modules.purchase_one_click
|
||||||
""",
|
""",
|
||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
test_loader='trytond.test_loader:Loader',
|
test_loader='trytond.test_loader:Loader',
|
||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
use_2to3=True,
|
use_2to3=True,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +1,2 @@
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
try:
|
|
||||||
from trytond.modules.one_click_for_purchase.tests.test_one_click_for_purchase import suite
|
|
||||||
except ImportError:
|
|
||||||
from .test_one_click_for_purchase import suite
|
|
||||||
|
|
||||||
__all__ = ['suite']
|
|
||||||
|
|
|
@ -1,20 +1,11 @@
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
|
|
||||||
from trytond.tests.test_tryton import ModuleTestCase
|
from trytond.tests.test_tryton import ModuleTestCase
|
||||||
from trytond.tests.test_tryton import suite as test_suite
|
|
||||||
|
|
||||||
|
|
||||||
class OneClickForPurchaseTestCase(ModuleTestCase):
|
class PurchaseOneClickTestCase(ModuleTestCase):
|
||||||
'Test One Click For Purchase module'
|
'Test One Click For Purchase module'
|
||||||
module = 'one_click_for_purchase'
|
module = 'purchase_one_click'
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
del ModuleTestCase
|
||||||
suite = test_suite()
|
|
||||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
|
||||||
OneClickForPurchaseTestCase))
|
|
||||||
return suite
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=6.0.0
|
version=6.8.0
|
||||||
depends:
|
depends:
|
||||||
ir
|
ir
|
||||||
purchase
|
purchase
|
||||||
xml:
|
xml:
|
||||||
purchase.xml
|
purchase.xml
|
||||||
message.xml
|
message.xml
|
Loading…
Reference in New Issue