Skip to main content

No project description provided

Project description

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file hb_tryton_sale_subscription_with_variable_amount-1.0.0.tar.gz.

File metadata

File hashes

Hashes for hb_tryton_sale_subscription_with_variable_amount-1.0.0.tar.gz
Algorithm Hash digest
SHA256 18b979cc087b08951a43f4f8c3ef6f2f7a17dc12bf3ec02502fcdcf7c0f50bec
MD5 5ec910b5348a3a681fe89b20906e531b
BLAKE2b-256 abdbe2999fbdf11bdf185bbc56eb62af4ec680f014f7fff5dd02220848996cfc

See more details on using hashes here.

File details

Details for the file hb_tryton_sale_subscription_with_variable_amount-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hb_tryton_sale_subscription_with_variable_amount-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74642a9567c70a94de3bed3dd316b9a59cbcaf7e93810d7a691a6d776bc38e95
MD5 1f03f1c4059d60c0b3531805a03c1f71
BLAKE2b-256 3ccf6e6bffc516318e8abcfe26903d12ecf8ee91137990d4b48d05ee279da369

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page