Since Tryton 6.0 had the awesome product kit module added I saved a lot of time and only had to add some custom logic for my extra fields.
After some discussion on the IRC channel I had a vague idea of what to do (write my own get_components was up for discussion,..)
In the end I found a really simple way to do what I wanted after playing around in proteus a bit and inspecting the data. Basically I am making use of <prefix>line.component_children.
Since the components of a kit are expanded on quotation I just added one more method to my customized Sale class:
@classmethod
@ModelView.button
@Workflow.transition('quotation')
@set_employee('quoted_by')
def quote(cls, sales):
super(Sale, cls).quote(sales)
# we need to apply folder_no to components of kits
for sale in sales:
for line in sale.lines:
for lc in line.component_children:
lc.folder_no = line.folder_no
lc.save()
cls.save(sales)
I am not 100% sure if the last cls.save(sales) is needed, but I thought rather be safe than sorry. Now my components have the same folder_no as the kits which is needed for my project documentation.
Share on Twitter Share on Facebook
Comments
There are currently no comments
New Comment