…
Install
Dependencies for ArchLinux
sudo pacman -S cairo pkgconf gobject-introspection
Dependencies for debian
sudo apt-get install libcairo2-dev libgirepository1.0-dev
Install the package
# installs python deps
pip install hb_tryton_sale_subscription_with_variable_amount
# install the module
trytond-admin -u sale_subscription_with_variable_amount --activate-dependencies
Install the db by hb-tryton-devtools
pip install git+https://gitlab.com/hashbangfr/tryton-modules/hb_tryton_devtools.git#egg=hb_tryton_devtools
export TRYTON_DATABASE_URI=postgresql:///
export TRYTON_DATABASE_NAME=test
hb-tryton-admin create-db --modules sale_subscription_with_variable_amount
Test package
The package need pytest and hb-tryton-devtools
pip install pytest pytest-cov
pip install git+ssh://git@gitlab.com/hashbangfr/tryton-modules/hb_tryton_devtools.git#egg=hb_tryton_devtools
Run the test with pytest with environ variable
export TRYTON_DATABASE_URI=postgresql:///
export TRYTON_DATABASE_NAME=test
pytest sale_subscription_with_variable_amount/tests
Usage
The goal of this module is to improve the sale_subcription to define variable amount.
The viariable amount will be get by variable quantity or variable unit price. By default the behaviour is the same as the main module sale_subscription with fixed quantity and fixed unit price.
The new object is sale.subscription.service.type, this modele defined hooks on the consumption line and the invoice line to put the good quantity and the good unit price.
It is possible to define the service type in Product / Configuration / Service types. The default service type can be added Product / Configuration / Configuration.
To define new hook you have to inherit the model
from trytond.pool import PoolMeta, Pool
class ServiceType(metaclass=PoolMeta):
__name__ = 'sale.subscription.service.type'
@classmethod
def __setup__(cls):
super(ServiceType, cls).__setup__()
cls.consumption_hook_.selection.append(
('timesheet', "Get quantity from the timesheet"))
cls.invoice_hook.selection.append(
('amount_grid_for_timesheep', "Get the unit price in function of quantity"))
def consumption_hook_timesheet(self, line):
# here another code on subscription line get the méthod to get the
# timesheet to invoice : this méthod is not describe here
nb_hours = line.line.get_hours_qty_to_invoice()
line.quantity = nb_hours
def invoice_hook_amount_grid_for_timesheep(self, line):
# a model define the grid, it is not the goal of this exemple to define
# this modele
Grid = Pool().get('amount_grid_for_timesheep')
unit_price = Grid.get_the_unitprice_for(line.quantity)
line.unit_price = unit_price
line.on_change_with_amount()
In the view formulaire some groups / page are added
sale.subscription.line [FORM] /form/notebook/page@id=hook_properties
sale.subscription.service [FORM] /form/group@id=hook_properties
sale.subscription.service.type [FORM] /form/group@id=hook_properties
this locations are defined to add easily all the need fields
CHANGELOG
1.0.0 (2022-05-17)
Added hook mecanisms to get quantity and unit price
Added configuration for the service type
Metadata
Release files for hb-tryton-sale-subscription-with-variable-amount 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hb_tryton_sale_subscription_with_variable_amount-1.0.0.tar.gz | 20.0 kB | Without provenance | Details for hb_tryton_sale_subscription_with_variable_amount-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hb_tryton_sale_subscription_with_variable_amount-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for hb_tryton_sale_subscription_with_variable_amount-1.0.0-py3-none-any.whl |
Total release size: 42.6 kB
Release files / hb_tryton_sale_subscription_with_variable_amount-1.0.0.tar.gz
| Download URL | hb_tryton_sale_subscription_with_variable_amount-1.0.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18b979cc087b08951a43f4f8c3ef6f2f7a17dc12bf3ec02502fcdcf7c0f50bec
|
|
BLAKE2b-256 checksum How to use checksums |
abdbe2999fbdf11bdf185bbc56eb62af4ec680f014f7fff5dd02220848996cfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.2
|
Release files / hb_tryton_sale_subscription_with_variable_amount-1.0.0-py3-none-any.whl
| Download URL | hb_tryton_sale_subscription_with_variable_amount-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74642a9567c70a94de3bed3dd316b9a59cbcaf7e93810d7a691a6d776bc38e95
|
|
BLAKE2b-256 checksum How to use checksums |
3ccf6e6bffc516318e8abcfe26903d12ecf8ee91137990d4b48d05ee279da369
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.2
|
Security for hb-tryton-sale-subscription-with-variable-amount 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.